<template>
  <div>
    <a-spin :spinning="confirmLoading" style="background: #fff">
      <j-form-container :disabled="false">
        <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">

          <a-collapse v-model="activeKey">
            <a-collapse-panel key="0" header="费用类别">

            <a-col :span="24">
                  <a-form-model-item label="费用类别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="feeCategory">
                    <j-dict-select-tag
                      :disabled="formDisabled || showFlowSubmitButton"
                      type="radio"
                      v-model="model.feeCategory"
                      dictCode="fee_category"
                      placeholder="请选择费用类别"
                      @backItem="radioCategory"/>
                  </a-form-model-item>
                  <div style="position: absolute;bottom: 8px;left: 26px;line-height: 14px;color: #666">{{ model.feeCategory=='0'?'职工薪酬类报销（不含集中采购的节日福利）':model.feeCategory=='1'?"需签订合同的采购类报销":"其他场景" }}</div>
                </a-col>
            </a-collapse-panel>
            <a-collapse-panel key="1" header="基本信息">
              <a-row :gutter="48">
                <a-col :span="8" :hidden="true">
                  <a-form-model-item label="标题" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bpmBizTitle">
                    <a-input
                      :disabled="formDisabled"
                      v-model="model.bpmBizTitle"
                      placeholder="请输入标题"
                      :max-length="255"
                    ></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="单据编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="billNo">
                    <a-input :disabled="formDisabled || billNoDisabled" v-model="model.billNo" placeholder="请输入单据编号" ></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="填表时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createTime">
                    <j-date
                      placeholder="请选择填表时间"
                      v-model="model.createTime"
                      :show-time="true"
                      date-format="YYYY-MM-DD HH:mm:ss"
                      style="width: 100%"
                      disabled/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="报销人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="proposer">
                    <select-user-by-dep
                      :multi="false"
                      v-model="model.proposer"
                      disabled></select-user-by-dep>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="所在部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="proposerDeptId">
                    <j-select-depart v-model="model.proposerDeptId" disabled/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="费用所属团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamId">
                    <select-team-input
                      isApi="expenseReimbursement"
                      :proposerDeptId="proposerDeptId"
                      :disabled="formDisabled || showFlowSubmitButton"
                      v-model="model.teamId"
                      :tdlx="3"
                      @back="selectTeam"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="申请公司" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applicant">
                    <select-Company-input :disabled="formDisabled || showFlowSubmitButton" v-model="model.applicant" @change="selectApplicant"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="团队费用类别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamFeeCategory">
                    <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.teamFeeCategory" dictCode="team_fee_category" placeholder="请选择团队费用类别" />
                  </a-form-model-item>
                </a-col>

                <a-col :span="8" v-if="model.teamYear=='2023'">
                  <a-form-model-item label="费用所属年度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamYear">
                    <j-dict-select-tag
                      type="list"
                      v-model="model.teamYear"
                      dictCode="tdnd_type"
                      placeholder="请选择费用所属年度"
                      disabled/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="单据类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="billCategory">
                    <j-dict-select-tag :disabled="formDisabled || showFlowSubmitButton" type="list" v-model="model.billCategory" dictCode="bill_category" placeholder="请选择单据类型" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="本次是否付款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isPay">
                    <j-dict-select-tag
                      @input="isPay"
                      :disabled="formDisabled || showFlowSubmitButton"
                      type="list"
                      v-model="model.isPay"
                      dictCode="is_pay"
                      placeholder="请选择本次是否付款" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="本次付款金额（元）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payAmount">
                    <a-input-number
                      :disabled="(formDisabled || isPayDisabled) && !showFlowSubmitButton"
                      :max="99999999"
                      :min="0"
                      v-model="model.payAmount"
                      placeholder="请输入本次付款金额"
                      style="width: 100%" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="累计报销金额（元）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accumulateAmount">
                    <a-input-number
                      :disabled="true"
                      :max="99999999"
                      :min="0"
                      v-model="model.accumulateAmount"
                      placeholder="请输入累计报销金额"
                      style="width: 100%" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="本次累计冲账金额（元）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chargedAmount">
                    <a-input-number
                      :disabled="true"
                      :max="99999999"
                      :min="0"
                      v-model="model.chargedAmount"
                      placeholder="请输入本次冲账金额"
                      style="width: 100%" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="是否使用商务卡" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isUseBusinessCard">
                    <j-dict-select-tag
                      :disabled="formDisabled || showFlowSubmitButton"
                      type="list"
                      v-model="model.isUseBusinessCard"
                      dictCode="YES_OR_NO"
                      placeholder="请选择是否使用商务卡" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="24">
                  <a-form-model-item label="报销说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applyExplain">
                    <a-textarea :disabled="formDisabled && !showFlowSubmitButton" v-model="model.applyExplain" rows="4" placeholder="请输入报销说明" :max-length="500"/>
                  </a-form-model-item>
                </a-col>

                <!-- <a-col v-if="showFlowSubmitButton" :span="24" style="text-align: center">
              <a-button @click="submitForm">提 交</a-button>
            </a-col> -->
              </a-row>
            </a-collapse-panel>
            <a-collapse-panel key="2" header="费用报销信息" >
              <a-row :gutter="48">
                <a-col :span="24">
                  <!--迭代 start 10TASK#3370 费用报销单-工资福利类修改为子表多条和新增累计报销金额字段 -->
                  <div v-if="model.feeCategory==0">
                    <div style="margin-bottom: 6px;margin-top: 6px;" >
                      <a-button @click="handleSalaryFeeInfoAdd" v-if="!formDisabled && !showFlowSubmitButton" type="primary">新增</a-button>
                    </div>
                    <a-table
                      ref="table"
                      size="middle"
                      rowKey="id"
                      bordered
                      :loading="loading"
                      :columns="salaryColumns"
                      :components="draggableComponentOther"
                      :pagination="false"
                      :data-source="model.salaryFeeInfoList"
                      :scroll="{x: scrollXOther}"
                    >
                      <span slot="action" slot-scope="text, record" >
                        <template v-if="!formDisabled">
                          <a-button
                            class="ruleButton"
                            :ghost="true"
                            type="primary"
                            icon="edit"
                            @click="handleSalaryFeeInfoEdit(record)"/>
                          <template v-if="!showFlowSubmitButton">
                            <a-divider type="vertical"/>
                            <a-popconfirm title="确定复制行吗?" @confirm="() => handleSalaryCopy(record)">
                              <a-button
                                class="ruleButton"
                                :ghost="true"
                                type="primary"
                                icon="copy"
                              />
                            </a-popconfirm>
                            <a-divider type="vertical"/>
                            <a-popconfirm title="确定删除吗?" @confirm="() => handleSalaryFeeInfoDelete(record.id)">
                              <a-button
                                class="ruleButton"
                                :ghost="true"
                                type="primary"
                                icon="delete"
                              />
                            </a-popconfirm>
                          </template>
                        </template>
                      </span>
                    </a-table>
                  </div>
                </a-col>
                <!--迭代 end 10TASK#3370 费用报销单-工资福利类修改为子表多条和新增累计报销金额字段 -->
                <div v-if="model.feeCategory==1">
                  <a-col :span="8">
                    <a-form-model-item label="采购大类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.bigCategory">
                      <a-select
                        v-model="model.purchaseyFeeInfo.bigCategory"
                        :disabled="formDisabled"
                        placeholder="请选择采购大类"
                        :showSearch="true"
                        :allowClear="true"
                        :filterOption="filterOption"
                        @change="handleChange"
                        :getPopupContainer="(triggerNode)=>{ return triggerNode.parentNode}"
                      >
                        <a-select-option v-for="item in provisionBroadList" :key="item.id" :value="item.id">{{ item.categoryName }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8">
                    <a-form-model-item label="采购小类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.smallCategory">
                      <a-select
                        v-model="model.purchaseyFeeInfo.smallCategory"
                        :disabled="formDisabled || !model.purchaseyFeeInfo.bigCategory"
                        placeholder="请选择采购小类"
                        :showSearch="true"
                        :allowClear="true"
                        :filterOption="filterOption"
                        :getPopupContainer="(triggerNode)=>{ return triggerNode.parentNode}"
                        @change="modifySmallCategory"
                      >
                        <a-select-option v-for="item in provisionSmallList" :key="item.id" :value="item.id">{{ item.categoryName }}</a-select-option>
                      </a-select>
                    </a-form-model-item>
                  </a-col>
                  <a-input :disabled="formDisabled" v-model="model.purchaseyFeeInfo.checkPosition" placeholder="审核岗位" :hidden="true"></a-input>
                  <a-col :span="8">
                    <a-form-model-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.projectId">
                      <a-input
                        v-if="formDisabled || showFlowSubmitButton"
                        readOnly
                        @click.prevent="goProjectDetail(model.purchaseyFeeInfo)"
                        v-model="model.projectName"
                        style="color: #1890FF; cursor: pointer;"
                        placeholder="请选择项目"></a-input>
                      <select-project-input
                        v-else
                        v-model="model.purchaseyFeeInfo.projectId"
                        placeholder="请选择项目"
                        :queryParamType="'1'"
                        :teamId="model.teamId"
                        :companyId="model.applicant"
                        :disabled="formDisabled || !model.teamId || !model.applicant"
                        @input="selectProject" />
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8">
                    <a-form-model-item label="项目编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.projectCode">
                      <a-input
                        disabled
                        v-model="model.purchaseyFeeInfo.projectCode"
                        placeholder="请输入项目编号"
                      ></a-input>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8">
                    <a-form-model-item label="业绩归属年度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="performanceAttributionYear">
                      <j-dict-select-tag
                        type="list"
                        v-model="model.purchaseyFeeInfo.performanceAttributionYear"
                        dictCode="yjgsnd"
                        placeholder="请选择业绩归属年度"
                        disabled/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8" v-if="!model.purchaseyFeeInfo.projectId">
                    <a-form-model-item label="关联采购合同" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.relContractId">
                      <a-input
                        v-if="formDisabled || showFlowSubmitButton"
                        readOnly
                        @click.prevent="goPurchaseContractDetail(model.purchaseyFeeInfo.relContractId)"
                        v-model="model.relContractBillName"
                        style="color: #1890FF; cursor: pointer;"
                        placeholder="请选择采购合同"></a-input>
                      <select-purchase-contract-input
                        v-else
                        :disabled="formDisabled || !model.teamId || !model.applicant"
                        :teamId="model.teamId"
                        :demandCompanName="model.applicant"
                        v-model="model.purchaseyFeeInfo.relContractId"
                        style="width: 100%"
                        placeholder="请选择采购合同"
                        @back="getContract" />
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8" v-else>
                    <a-form-model-item label="关联采购合同" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.relContractId">
                      <a-input
                        v-if="formDisabled || showFlowSubmitButton"
                        readOnly
                        @click.prevent="goContractDetail(model.purchaseyFeeInfo.relContractId)"
                        v-model="model.relContractBillName"
                        style="color: #1890FF; cursor: pointer;"
                        placeholder="请选择合同"></a-input>
                      <select-contract-manager-input
                        v-else
                        showName="1"
                        isCategoryType="1"
                        :muitFlag="true"
                        :disabled="formDisabled || !model.purchaseyFeeInfo.projectId"
                        :projectId="model.purchaseyFeeInfo.projectId"
                        htlx="2"
                        v-model="model.purchaseyFeeInfo.relContractId"
                        style="width: 100%"
                        @back="getProjectContract" />
                    </a-form-model-item>
                  </a-col>
                  <!-- <a-col :span="8">
                  <a-form-model-item label="关联团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamId">
                    <select-team-input
                    :disabled=formDisabled
                    v-model="model.purchaseyFeeInfo.teamId" :tdlx="3" disabled/>
                  </a-form-model-item>
                </a-col> -->
                  <a-col :span="8">
                    <a-form-model-item label="发票类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.isSpecial">
                      <!-- 迭代八需求 - 发票类型下拉增加一个”其他“选项，其他和普票相同。 -->
                      <j-dict-select-tag
                        :disabled="formDisabled && !showFlowSubmitButton"
                        type="list"
                        v-model="model.purchaseyFeeInfo.isSpecial"
                        @input="isSpecial(2)"
                        dictCode="cost_invoice_type"
                        placeholder="请选择发票类型"/>
                    <!-- <j-dict-select-tag :disabled=formDisabled type="list" @input="isSpecial(2)" v-model="model.purchaseyFeeInfo.isSpecial" dictCode="is_special" placeholder="请选择专票属性" /> -->
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8" v-if="model.purchaseyFeeInfo.projectId">
                    <a-form-model-item label="收款合同金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.contractTotalAmount">
                      <a-input-number
                        :max="99999999"
                        :min="0"
                        v-model="model.purchaseyFeeInfo.contractTotalAmount"
                        placeholder="请输入收款合同金额"
                        style="width: 100%"
                        disabled />
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8" v-if="model.purchaseyFeeInfo.projectId">
                    <a-form-model-item label="项目已回款金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.contractActualCollectAmount">
                      <a-input-number
                        :max="99999999"
                        :min="0"
                        v-model="model.purchaseyFeeInfo.contractActualCollectAmount"
                        placeholder="请输入项目已回款金额"
                        style="width: 100%"
                        disabled />
                    </a-form-model-item>
                  </a-col>
                  <!-- <a-col :span="8"  v-if="!model.purchaseyFeeInfo.projectId">
                  <a-form-model-item label="合同款项" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.contractPaymentId">
                    <select-purchase-contract-payment-input :multi="true" :disabled="formDisabled || !model.purchaseyFeeInfo.relContractId" v-model="model.purchaseyFeeInfo.contractPaymentId" :purchaseBill="model.purchaseyFeeInfo.relContractId" style="width: 100%" placeholder="请选择合同款项"  @back="getContractPayment"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8" v-else>
                  <a-form-model-item label="合同款项" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.contractPaymentId">
                    <select-checkoutlist-input multi :disabled="formDisabled || !model.purchaseyFeeInfo.relContractId" v-model="model.purchaseyFeeInfo.contractPaymentId" :contractNo="model.purchaseyFeeInfo.relContractId" @back="getCheckoutInfo" placeholder="请选择合同款项" title="项目采购合同款项"/>
                  </a-form-model-item>
                </a-col> -->
                  <!-- <a-col :span="8">
                  <a-form-model-item label="付款比例" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.paymentProportion">
                    <a-input :disabled=formDisabled :max="99999999" :min="0" addon-after="%"  v-model="model.purchaseyFeeInfo.paymentProportion" placeholder="请输入付款比例" style="width: 100%" disabled/>
                  </a-form-model-item>
                </a-col> -->
                <a-col :span="8">
                  <!-- 迭代八需求 - 费用类别-采购类-费用报销信息-付款金额改为应付款金额 -->
                  <a-form-model-item label="应付款金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.paymentAmount">
                    <a-input-number :max="99999999" :min="0" v-model="model.purchaseyFeeInfo.paymentAmount" placeholder="请输入应付款金额" style="width: 100%" disabled />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="已付金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.collectedAmount">
                    <a-input-number :max="99999999" :min="0" v-model="model.purchaseyFeeInfo.collectedAmount" placeholder="请输入已付金额" style="width: 100%" disabled />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="未付金额（含扣款）(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.unpaymentAmount">
                    <a-input-number :max="99999999" :min="0" v-model="model.purchaseyFeeInfo.unpaymentAmount" placeholder="请输入未付金额" style="width: 100%" disabled />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="报销金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.amount">
                    <a-input-number :disabled="formDisabled && !showFlowSubmitButton" :max="99999999" :min="0" v-model="model.purchaseyFeeInfo.amount" placeholder="请输入报销金额" style="width: 100%"  @blur="inputAmount(2)"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="税费金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.taxation">
                    <a-input-number :disabled="formDisabled || isSpecialDisabled" :max="Number(model.purchaseyFeeInfo.amount)" :min="0"  v-model="model.purchaseyFeeInfo.taxation" placeholder="请输入税费金额"  @blur="inputAmount(2)" style="width: 100%" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="未税金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.untaxedAmount">
                    <a-input-number :max="99999999" :min="0"  v-model="model.purchaseyFeeInfo.untaxedAmount" placeholder="请输入未税金额" style="width: 100%" disabled />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="税率(%)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseyFeeInfo.taxRate">
                    <a-input-number :disabled="formDisabled || isTaxRateDisabled" :max="99999999" :min="0" :precision="0" v-model="model.purchaseyFeeInfo.taxRate" placeholder="请输入税率" style="width: 100%" />
                  </a-form-model-item>
                </a-col>
              </div>
                <a-col :span="24" v-if="model.feeCategory==2">
                  <a-col :span="24">
                    <a-form-model-item label="是否关联项目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isRelProject">
                      <j-dict-select-tag :disabled="formDisabled || model.dailyFeeInfoList.length>0?true:false" type="radio" v-model="model.isRelProject" dictCode="is_rel_project" placeholder="请选择是否关联项目" />
                    </a-form-model-item>
                  </a-col>
                  <div style="margin-bottom: 6px;margin-top: 6px" >
                    <a-button @click="handleAdd" v-if="!formDisabled && !showFlowSubmitButton" type="primary">新增</a-button>
                  </div>
                  <a-table
                    ref="table"
                    size="middle"
                    rowKey="id"
                    bordered
                    :loading="loading"
                    :components="draggableComponent"
                    :columns="model.isRelProject=='1'?columns:precolumns"
                    :pagination="false"
                    :data-source="model.dailyFeeInfoList"
                    :scroll="{x: scrollX}"
                  >
                    <span slot="projectId" slot-scope="text, record">
                      <a @click="goProjectDetail(record)">{{ loadProjectDetail(text) }}</a>
                    </span>
                    <span slot="action" slot-scope="text, record">
                      <template v-if="!formDisabled">
                        <a-button
                          class="ruleButton"
                          :ghost="true"
                          type="primary"
                          icon="edit"
                          @click="handleEdit(record)"/>
                        <template v-if="!showFlowSubmitButton">
                          <a-divider type="vertical"/>
                          <a-popconfirm title="确定复制行吗?" @confirm="() => handleCopy(record)">
                            <a-button
                              class="ruleButton"
                              :ghost="true"
                              type="primary"
                              icon="copy"
                            />
                          </a-popconfirm>
                          <a-divider type="vertical"/>
                          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                            <a-button
                              class="ruleButton"
                              :ghost="true"
                              type="primary"
                              icon="delete"
                            />
                          </a-popconfirm>
                        </template>
                      </template>
                    </span>
                  </a-table>
                </a-col>
                <a-col :span="24">
                  <a-form-model-item label="结算方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="settleType" v-if="model.isPay=='1'" >
                    <j-dict-select-tag
                      v-if="model.isPay=='1'"
                      :disabled="formDisabled || showFlowSubmitButton"
                      type="list"
                      v-model="model.settleType"
                      dictCode="settle_type"
                      placeholder="请选择结算方式"
                      @input="radioSettleType"/>
                  <!-- <j-dict-select-tag v-if="model.isPay=='0'" :disabled=formDisabled type="list" v-model="model.settleType" dictCode="settle_type_false" placeholder="请选择结算方式" @input="radioSettleType"/> -->
                  </a-form-model-item>
                </a-col>
              </a-row>
              <template v-if="this.model.settleType==0 && model.isPay=='1'">
                <a-row :gutter="48">
                  <a-col :span="8">
                    <a-form-model-item label="转账类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="transferType" v-if="model.isPay=='1'" >
                      <j-dict-select-tag
                        :disabled="formDisabled || showFlowSubmitButton"
                        type="list"
                        v-model="model.transferType"
                        dictCode="transfer_type"
                        placeholder="请选择转账类型"
                        @input="radioTransferType"/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8" v-if="model.transferType">
                    <a-form-model-item label="收款户名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountName">
                      <SelectSupplierInput
                        v-if="model.transferType=='2'"
                        :isFinance="true"
                        :disabled="formDisabled || showFlowSubmitButton"
                        v-model="model.accountName"
                        @back="selectCustomer"/>
                      <select-user-by-dep
                        :disabled="formDisabled || showFlowSubmitButton"
                        :multi="false"
                        v-model="model.accountName"
                        v-if="model.transferType=='1'"
                        @back="selectAccountName"></select-user-by-dep>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8" v-if="model.accountName">
                    <a-form-model-item label="收款方开户行" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankName">
                      <!-- <a-input :disabled="formDisabled || showFlowSubmitButton" v-model="model.bankName" placeholder="请输入收款方开户行" ></a-input> -->
                      <a-input v-model="model.bankName" placeholder="请输入收款方开户行" disabled></a-input>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8" v-if="model.accountName">
                    <a-form-model-item label="开户行联行号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cnapsCode">
                      <a-input v-model="model.cnapsCode" placeholder="请输入开户行联行号" disabled></a-input>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8" v-if="model.accountName">
                    <a-form-model-item label="收款方银行账户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountNo">
                      <!-- <a-input :disabled="formDisabled || showFlowSubmitButton" v-model="model.accountNo" :max-length="32" placeholder="请输入收款方银行账户" ></a-input> -->
                      <a-input v-model="model.accountNo" :max-length="32" placeholder="请输入收款方银行账户" disabled></a-input>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="24" v-if="model.accountName">
                    <a-form-model-item label="打款附言" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postscript">
                      <a-textarea :disabled="formDisabled && !showFlowSubmitButton" v-model="model.postscript" rows="3" placeholder="请输入打款附言" :max-length="200"/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </template>
              <template v-if="model.isPay" >
                <a-row :gutter="48">
                  <a-col :span="8">
                    <a-form-model-item label="冲账单据类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="relBillType">
                      <j-dict-select-tag
                        :disabled="formDisabled || showFlowSubmitButton"
                        type="list"
                        v-if="model.feeCategory=='2' && model.isRelProject=='1' && model.dailyFeeInfoList.length!=0"
                        v-model="model.relBillType"
                        dictCode="rel_bill_type"
                        placeholder="请选择冲账单据类型"
                        @input="radioChange" />
                      <j-dict-select-tag
                        :disabled="formDisabled || showFlowSubmitButton"
                        type="list"
                        v-else
                        v-model="model.relBillType"
                        dictCode="rel_bill_type_no_project"
                        placeholder="请选择冲账单据类型"
                        @input="radioChange" />
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="16">
                    <a-form-model-item label="关联单据单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="relBillId" v-if="model.relBillType==3">
                      <!-- <template  v-if="model.relBillType==2">
                        <a-input v-if="formDisabled" readOnly @click.prevent="goDetail(model.relBillId)"  v-model="model.relBillNo" style="color: #1890FF; cursor: pointer;"  placeholder="请选择付款单单据"></a-input>
                        <select-finance-payment-bill-input v-else :disabled="formDisabled || !model.teamId || !model.applicant" v-model="model.relBillId" :teamId="model.teamId" :applicant="model.applicant" @back="relBillData" placeholder="请选择关联单据单号" />
                      </template>
                      <template  v-if="model.relBillType==1">
                        <a-input v-if="formDisabled" readOnly @click.prevent="goDetail(model.relBillId)"  v-model="model.relBillNo" style="color: #1890FF; cursor: pointer;"  placeholder="请选择借款单单据"></a-input>
                        <select-finance-loan-bill-input v-else  :disabled="formDisabled || !model.teamId || !model.applicant" v-model="model.relBillId" :teamId="model.teamId" :applicant="model.applicant"  @back="relBillData" placeholder="请选择关联单据单号" />
                      </template> -->
                      <template v-if="model.relBillType==3">
                        <a-input
                          v-if="formDisabled || showFlowSubmitButton"
                          readOnly
                          @click.prevent="goDetail(model.relBillId)"
                          v-model="model.relBillNo"
                          style="color: #1890FF; cursor: pointer;"
                          placeholder="请选择保证金单据"></a-input>
                        <select-finance-deposit-bill-input
                          v-else
                          :disabled="formDisabled || !model.teamId || !model.applicant || model.dailyFeeInfoList.length==0"
                          v-model="model.relBillId"
                          :teamId="model.teamId"
                          :projectId="projectId"
                          :applicant="model.applicant"
                          :feeCategory="'1,2'"
                          @back="relBillData"
                          placeholder="请选择关联单据单号" />
                      </template>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="24">
                    <template v-if="model.relBillType=='1' || model.relBillType=='2'">
                      <div>
                        <div style="margin-bottom: 6px;margin-top: 6px;" >
                          <a-button @click="handleChargedInfoAdd" v-if="!formDisabled && !showFlowSubmitButton" type="primary">新增</a-button>
                        </div>
                        <a-table
                          ref="table"
                          size="middle"
                          rowKey="id"
                          :loading="loading"
                          :columns="model.relBillType=='1'?chargedLoanColumns:chargedPayColumns"
                          :pagination="false"
                          :data-source="model.chargedInfoList"
                          :scroll="{x: true}"
                        >
                          <span slot="relBillId" slot-scope="text, record">
                            <a @click="goDetail(record.relBillId)">{{ loadBillDetail(text) }}</a>
                          </span>
                          <span slot="action" slot-scope="text, record">
                            <template v-if="!formDisabled">
                              <a-button
                                class="ruleButton"
                                :ghost="true"
                                type="primary"
                                icon="edit"
                                @click="handleChargedInfoEdit(record)"/>
                              <template v-if="!showFlowSubmitButton">
                                <a-divider type="vertical"/>
                                <a-popconfirm title="确定删除吗?" @confirm="() => handleChargedInfoDelete(record.id)">
                                  <a-button
                                    class="ruleButton"
                                    :ghost="true"
                                    type="primary"
                                    icon="delete"
                                  />
                                </a-popconfirm>
                              </template>
                            </template>
                          </span>
                        </a-table>
                      </div>

                    <!-- <a-col :span="8" >
                      <a-form-model-item label="借款金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="borrowLoanAmount" >
                        <a-input-number :disabled=formDisabled :max="99999999" :min="0"  :precision="2" v-model="model.borrowLoanAmount" placeholder="请输入借款金额" style="width: 100%" disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-model-item label="已还金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="borrowOnloanAmount">
                        <a-input-number :disabled=formDisabled :max="99999999" :min="0"  :precision="2" v-model="model.borrowOnloanAmount" placeholder="请输入已还金额" style="width: 100%" disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-model-item label="未还金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="borrowUnloanAmount">
                        <a-input-number :disabled=formDisabled :max="99999999" :min="0"  :precision="2" v-model="model.borrowUnloanAmount" placeholder="请输入未还金额" style="width: 100%" disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="24" >
                      <a-form-model-item label="剩余未付金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="borrowPayAmount">
                        <a-input-number :disabled=formDisabled :max="99999999" :min="0"  :precision="2" v-model="model.borrowPayAmount" placeholder="请输入剩余未付金额" style="width: 100%" disabled/>
                      </a-form-model-item>
                    </a-col> -->
                    </template>
                  </a-col>
                  <template v-if="model.relBillType=='2'">
                    <!-- <a-col :span="8" >
                      <a-form-model-item label="申请公司" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payApplicant" >
                        <select-Company-input :disabled="formDisabled" v-model="model.payApplicant" disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-model-item label="收款单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payPayeeName" >
                        <select-customer-input  :disabled="formDisabled" v-model="model.payPayeeName" commercialType="1"  disabled/>
                      </a-form-model-item>
                    </a-col> -->
                    <!-- <a-col :span="8" >
                      <a-form-model-item label="预付金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payPayableAmount">
                        <a-input-number :disabled=formDisabled :max="99999999" :min="0" :precision="2"  v-model="model.payPayableAmount" placeholder="请输入预付金额" style="width: 100%" disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8" >
                      <a-form-model-item label="已冲账金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payOnChargedAmount">
                        <a-input-number :disabled=formDisabled :max="99999999" :min="0"  :precision="2" v-model="model.payOnChargedAmount" placeholder="请输入已冲账金额" style="width: 100%" disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8" >
                      <a-form-model-item label="未冲账金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payUnChargedAmount">
                        <a-input-number :disabled=formDisabled :max="99999999" :min="0"  :precision="2" v-model="model.payUnChargedAmount" placeholder="请输入未冲账金额" style="width: 100%" disabled/>
                      </a-form-model-item>
                    </a-col> -->
                    <!-- <a-col :span="8" >
                      <a-form-model-item label="应付金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payPaidAmount"   >
                        <a-input-number :disabled=formDisabled :max="99999999" :min="0"  v-model="model.payPaidAmount" placeholder="请输入应付金额" style="width: 100%" disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8" >
                      <a-form-model-item label="扣款金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payDeductionAmount">
                        <a-input-number :disabled=formDisabled :max="99999999" :min="0"  v-model="model.payDeductionAmount" placeholder="请输入扣款金额" style="width: 100%" disabled/>
                      </a-form-model-item>
                    </a-col> -->
                  </template>
                  <template v-if="model.relBillType=='3'">
                    <a-col :span="8" >
                      <a-form-model-item label="保证金总额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="depositRemittanceAmount">
                        <a-input-number
                          :max="99999999"
                          :min="0"
                          :precision="2"
                          v-model="model.depositRemittanceAmount"
                          placeholder="请输入保证金总额"
                          style="width: 100%"
                          disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8" >
                      <a-form-model-item label="服务费(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="depositServiceCharge" >
                        <a-input-number
                          :max="99999999"
                          :min="0"
                          :precision="2"
                          v-model="model.depositServiceCharge"
                          placeholder="请输入服务费"
                          style="width: 100%"
                          disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8" >
                      <a-form-model-item label="利息金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="depositInterestAmount">
                        <a-input-number
                          :max="99999999"
                          :min="0"
                          :precision="2"
                          v-model="model.depositInterestAmount"
                          placeholder="请输入利息金额"
                          style="width: 100%"
                          disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8" >
                      <a-form-model-item label="归还金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="depositReturnAmount">
                        <a-input-number
                          :max="99999999"
                          :min="0"
                          :precision="2"
                          v-model="model.depositReturnAmount"
                          placeholder="请输入归还金额"
                          style="width: 100%"
                          disabled/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8" >
                      <a-form-model-item label="未归还金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="depositUnreturnAmount">
                        <a-input-number
                          :max="99999999"
                          :min="0"
                          :precision="2"
                          v-model="model.depositUnreturnAmount"
                          placeholder="请输入未归还金额"
                          style="width: 100%"
                          disabled/>
                      </a-form-model-item>
                    </a-col>
                  </template>
                </a-row>
              </template>
              <!--            <a-col :span="24">-->
              <!--              <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">-->
              <!--                <a-textarea :disabled=formDisabled v-model="model.remark" rows="4" placeholder="请输入备注" :max-length="500"/>-->
              <!--              </a-form-model-item>-->
              <!--            </a-col>-->
            </a-collapse-panel>
            <a-collapse-panel key="3" header="附件信息" >
              <a-row :gutter="48">
                <a-col :span="24">
                  <a-form-model-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachments">
                    <j-upload :disabled="formDisabled || showFlowSubmitButton" v-model="model.attachments" ></j-upload>
                  </a-form-model-item>
                </a-col>
              </a-row>
            </a-collapse-panel>
          </a-collapse>
        </a-form-model>
        <common-flow-list v-if="formBpm && model.bpmStatus !== '1'" :formData="formData" style="margin-top: 10px"></common-flow-list>
        <!--子表表单-->
        <erp-finance-reimbursement-charged-bill-info-modal
          ref="chargedInfo"
          @ok="modalChargedInfoFormOk"
          :relBillType="model.relBillType"
          :teamId="model.teamId"
          :applicant="model.applicant"
          :showFlowSubmitButton="showFlowSubmitButton"> </erp-finance-reimbursement-charged-bill-info-modal>
        <erp-finance-reimbursement-salary-fee-modal ref="salaryFee" @ok="modalSalaryFeeInfoFormOk"></erp-finance-reimbursement-salary-fee-modal>
        <erp-finance-reimbursement-daily-fee-info-modal ref="dailyFee" @ok="modalFormOk" :teamId="model.teamId" :applicant="model.applicant" :showFlowSubmitButton="showFlowSubmitButton"></erp-finance-reimbursement-daily-fee-info-modal>
        <ErpFinanceDepositBillPenetrate ref="depositBillPenetrate"></ErpFinanceDepositBillPenetrate>
        <ErpFinancePaymentBillPenetrate ref="paymentBillPenetrate"></ErpFinancePaymentBillPenetrate>
        <ErpFinanceLoanBillPenetrate ref="loanBillPenetrate"></ErpFinanceLoanBillPenetrate>
        <!-- 项目详情开始 -->
        <erp-project-report-modal ref="projectReport"></erp-project-report-modal>
        <!-- 项目详情结束 -->
        <ErpPurchaseContractPenetrate ref="erpPurchaseContractPenetrate"></ErpPurchaseContractPenetrate>
        <ErpContractManagerPenetrate ref="erpContractManagerPenetrate"></ErpContractManagerPenetrate>
      </j-form-container>
      <a-row :gutter="48">
        <a-col :span="24" style="text-align: center;margin-top: 15px">
          <a-button type="primary" v-if="formBpm" :style="{ marginRight: showFlowSubmitButton?'10px':'0px' }" @click="onPrint">打印</a-button>
          <a-button @click="submitForm('submit')" v-if="showFlowSubmitButton">提 交</a-button>
        </a-col>
      </a-row>

      <ErpFinanceReimbursementBillFormPrint v-if="formBpm && isSubmit" class="print_style" id="reimbursementContent" :formData="model1" :formDataHistory="formData"></ErpFinanceReimbursementBillFormPrint>
    </a-spin>
  </div>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import moment from 'moment'
  import { mapGetters } from 'vuex'
  import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
  import SelectPersonInput from '@/views/scy/components/SelectPersonInput'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import { filterMultiDictText, initDictOptions } from '@/components/dict/JDictSelectUtil'
  import ErpFinanceReimbursementDailyFeeInfoModal from './ErpFinanceReimbursementDailyFeeInfoModal'
  import SelectFinanceLoanBillInput from '@/views/scy/components/SelectFinanceLoanBillInput'
  import SelectFinancePaymentBillInput from '@/views/scy/components/SelectFinancePaymentBillInput'
  import SelectContractManagerInput from '@/views/scy/components/SelectContractManagerInput'
  import SelectPurchaseContractInput from '@/views/scy/components/SelectPurchaseContractInput'
  import SelectProjectInput from '@/views/scy/components/SelectProjectInput'
  import SelectPurchaseContractPaymentInput from '@/views/scy/components/SelectPurchaseContractPaymentInput'
  import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
  import SelectSupplierInput from '@/views/scy/components/selectSupplier/SelectSupplierInput.vue'
  import SelectFinanceDepositBillInput from '@/views/scy/components/SelectFinanceDepositBillInput'
  import JDictSelectCategory from '@/components/dict/JDictSelectCategory.vue'
  import ErpFinanceReimbursementSalaryFeeModal from './ErpFinanceReimbursementSalaryFeeModal'
  import ErpFinanceReimbursementChargedBillInfoModal from './ErpFinanceReimbursementChargedBillInfoModal'
  import ErpFinanceDepositBillPenetrate from '@/views/scy/penetrate/ErpFinanceDepositBillPenetrate'
  import ErpFinancePaymentBillPenetrate from '@/views/scy/penetrate/ErpFinancePaymentBillPenetrate'
  import ErpFinanceLoanBillPenetrate from '@/views/scy/penetrate/ErpFinanceLoanBillPenetrate'
  import SelectCheckoutlistInput from '@/views/scy/components/SelectCheckoutlistInput'
  import CommonFlowList from '@/views/components/CommonFlowList.vue';
  import ErpFinanceReimbursementBillFormPrint from './ErpFinanceReimbursementBillFormPrint'
  import Print from '@/utils/print/printarea.js';
  import { DragResizable } from '@/mixins/DragResizable'
  import ErpProjectReportModal from '@/views/erp/report/project/modules/ErpProjectReportModal'

  export default {
    name: 'ErpFinanceReimbursementBillForm',
    mixins: [DragResizable],
    components: {
      JDictSelectCategory,
      SelectFinanceDepositBillInput,
      SelectSupplierInput,
      SelectCompanyInput,
      SelectProjectInput,
      SelectCheckoutlistInput,
      SelectUserByDep,
      SelectPersonInput,
      SelectTeamInput,
      SelectFinanceLoanBillInput,
      ErpFinanceReimbursementChargedBillInfoModal,
      ErpFinanceReimbursementDailyFeeInfoModal,
      SelectContractManagerInput,
      SelectFinancePaymentBillInput,
      SelectPurchaseContractInput,
      SelectPurchaseContractPaymentInput,
      ErpFinanceReimbursementSalaryFeeModal,
      ErpFinanceDepositBillPenetrate,
      ErpFinancePaymentBillPenetrate,
      ErpFinanceLoanBillPenetrate,
      CommonFlowList,
      ErpProjectReportModal,
      ErpFinanceReimbursementBillFormPrint,
      ErpPurchaseContractPenetrate: () => import('@/views/scy/penetrate/ErpPurchaseContractPenetrate'),
      ErpContractManagerPenetrate: () => import('@/views/scy/penetrate/ErpContractManagerPenetrate')
    },
    props: {
      // 流程表单data
      formData: {
        type: Object,
        default: () => {},
        required: false
      },
      // 表单模式：true流程表单 false普通表单
      formBpm: {
        type: Boolean,
        default: false,
        required: false
      },
      // 表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      },
      // 是否详情
      detail: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    watch: {
      activeKey(key) {
        this.$forceUpdate()
      }
    },
    data () {
      return {
        isSubmit: true,
        projectId: '',
        proposerDeptId:'',
        isSpecialDisabled: false, // 采购类型判断税费金额是否可编辑
        isTaxRateDisabled: false, // 采购类型判断税率是否可编辑
        billNoDisabled: true, // 是否单号
        isPayDisabled: false, // 是否付款
        activeKey: ['0','1', '2', '3'],
        provisionSmallList: [],
        provisionBroadList: [],
        model: {
          feeCategory: '0',
          salaryFeeInfoList: [],
          purchaseyFeeInfo: {
            taxation: 0
          },
          isRelProject: '1',
          dailyFeeInfoList: [],
          chargedInfoList: []
        },
        model1: {
          feeCategory: '0',
          salaryFeeInfoList: [],
          purchaseyFeeInfo: {
            taxation: 0
          },
          isRelProject: '1',
          dailyFeeInfoList: [],
          chargedInfoList: []
        },
        labelCol: {
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 }
        },
        confirmLoading: false,
        validatorRules: {
          bpmBizTitle: [
              { required: true, message: '请输入流程标题!' }
          ],
          // salaryFeeInfo:{
          //   bigCategory:[{ required: true, message: '请输入工资福利大类!'}],
          //   smallCategory:[{ required: true, message: '请输入工资福利小类!'},],
          //   amount:[ { required: true,pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},],
          //   isSpecial:[ { required: true, message: '请选择发票类型!'},]
          // },purchaseyFeeInfo.
          purchaseyFeeInfo: {
            bigCategory: [{ required: true, message: '请选择采购大类!' }],
            smallCategory: [{ required: true, message: '请选择采购小类!' } ],
            amount: [ { required: true, pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' } ],
            // 迭代10#TASK3371 费用报销单-采购类-费用报销信息-关联采购合同改为必填项
            relContractId: [
              { required: true, message: '请选择关联采购合同!' }
            ],
            isSpecial: [ { required: true, message: '请选择发票类型!' } ],
            contractPaymentId: [{ required: true, message: '请选择合同款项!' } ],
            taxRate: [
              { required: true, message: '请输入正确的税率!' }
            ]
          },
          billCategory: [
              { required: true, message: '请选择单据类型!' }
          ],
          teamFeeCategory: [
              { required: true, message: '请选择团队费用类别!' }
          ],
          teamId: [
              { required: true, message: '请选择费用所属团队!' }
          ],
          payAmount: [
            { required: true, pattern: /^(([1-9][0-9]*|0)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' }
          ],
          applyExplain: [
              { required: true, message: '请输入报销说明!' }
          ],
          applicant: [
              { required: true, message: '请选择申请公司!' }
          ],
          isPay: [
              { required: true, message: '请选择是否付款!' }
          ],
          isUseBusinessCard: [
            { required: true, message: '请选择是否使用商务卡!' }
          ],
          isUseBusinessCard: [
            { required: true, message: '请选择是否使用商务卡!' }
          ],
          feeCategory: [
              { required: true, message: '请选择费用类别!' }
          ],
          settleType: [
              { required: true, message: '请选择结算方式!' }
          ],
          accountName: [
              { required: true, message: '请输入收款户名!' }
          ],
          bankName: [
              { required: true, message: '请输入收款方开户行!' }
          ],
          cnapsCode: [
              { required: true, message: '请输入开户行联行号!' }
          ],
          accountNo: [
            { required: true, message: '请输入收款方银行账户!' }
              // { pattern: /^[1-9]{1}\d{7,29}$/, message: '请输入正确的银行账户!' },
          ],
          postscript: [
            { required: true, message: '请输入打款附言!' }
          ],
          relBillType: [
              { required: true, message: '请选择冲账类型!' }
          ],
          transferType: [
              { required: true, message: '请选择转账类型!' }
          ],
          relBillId: [
              { required: true, message: '请选择关联的单据!' }
          ]
          // onloanAmount:[ { required: false,pattern: /^(([1-9][0-9]*|0)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},],
          // unloanAmount:[ { required: false,pattern: /^(([1-9][0-9]*|0)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},],
          // loanAmount:[ { required: false,pattern: /^(([1-9][0-9]*|0)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},]
        },
        url: {
          queryProjectReportById: '/api/erp/project/report/erpProjectReport/queryById',
          queryFileById: '/api/erp/files/employee/erpEmployeeFile/queryFileById',
          getBillNo: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/getBillNo',
          add: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/add',
          edit: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/edit',
          queryById: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/queryById',
          queryProvisionBroadList: '/api/erp/purchase/material/erpMaterialCategory/queryAllParent',
          queryProvisionSmallList: '/api/erp/purchase/material/erpMaterialCategory/queryChildrenByParentId',
          qeuryPaymentBillById: '/api/erp/finance/payment/erpFinancePaymentSlip/queryById',
          qeuryLoanBillById: '/api/erp/finance/borrow/erpFinanceLoanBill/queryById',
          qeuryDepositBillById: '/api/erp/finance/deposit/erpFinanceProjectDepositBill/queryById',
          queryPurchaseContractById: '/api/erp/purchase/contract/erpPurchaseContract/queryById',
          queryContractById: '/api/erp/omc/contractmanager/erpOmcContractManagerFinal/queryById',
          queryContractByProjectId: 'api/erp/omc/contractmanager/erpOmcContractManagerFinal/list2',
          queryCharagedListById: '/api/erp/finance/reimbursement/erpFinanceReimbursementChargedBillInfo/queryBillById'
        },
        loading: false,
        dictOptions: {},
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '项目名称',
            align: 'center',
            dataIndex: 'projectId',
            width: 200,
            ellipsis: true,
            scopedSlots: { customRender: 'projectId' }
          },
          {
            title: '项目编号',
            align: 'center',
            width: 200,
            dataIndex: 'projectCode',
            ellipsis: true
          },
          {
            title:'业绩归属年度',
            align:"center",
            width: 120,
            ellipsis: true,
            dataIndex: 'performanceAttributionYear',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['performanceAttributionYear'], text + '')
              }
            }
          },
          {
            title: '合同名称',
            align: 'center',
            dataIndex: 'relContractId',
            width: 200,
            ellipsis: true,
            customRender: (text, r) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['relContractId'], text + '')
              }
            }
          },
          {
            title: '任务分类',
            align: 'center',
            dataIndex: 'taskCategory',
            width: 120,
            ellipsis: true,
            customRender: (text, r) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['taskCategory'], text + '')
              }
            }
          },
          // {
          //   title:'任务说明',
          //   align:"center",
          //   dataIndex: 'taskName',
          // },
          // 迭代八需求文档 - 3.1.9 费用报销单 费用类别-费用类-费用报销信息-子表-新增（含列表）删除费用所属团队和费用所属年度两个字段
          // {
          //   title:'费用所属年度',
          //   align:"center",
          //   dataIndex: 'teamYear',
          //   customRender: (text) => {
          //     if (!text) {
          //       return ''
          //     } else {
          //       return filterMultiDictText(this.dictOptions['teamYear'], text + '')
          //     }
          //   }
          // },
          // {
          //   title:'费用所属团队',
          //   align:"center",
          //   dataIndex: 'teamId',
          //   customRender: (text) => {
          //     if (!text) {
          //       return ''
          //     } else {
          //       return filterMultiDictText(this.dictOptions['teamId'], text + '')
          //     }
          //   }
          // },
          {
            title: '费用大类',
            align: 'center',
            dataIndex: 'bigCategory',
            width: 120,
            ellipsis: true,
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['bigCategory'], text + '')
              }
            }
          },
          {
            title: '费用小类',
            align: 'center',
            dataIndex: 'smallCategory',
            width: 120,
            ellipsis: true,
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['smallCategory'], text + '')
              }
            }
          },
          {
            title: '发票类型',
            align: 'center',
            dataIndex: 'isSpecial',
            width: 120,
            ellipsis: true,
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['isSpecial'], text + '')
              }
            }
          },
          {
            title: '报销金额（元）',
            align: 'center',
            dataIndex: 'amount',
            width: 120,
            ellipsis: true
          },
          {
            title: '税费金额（元）',
            align: 'center',
            dataIndex: 'taxation',
            width: 120,
            ellipsis: true
          },
          {
            title: '未税金额(元)',
            align: 'center',
            dataIndex: 'untaxedAmount',
            width: 120,
            ellipsis: true
          },
          {
            title: '税率(%)',
            align: 'center',
            dataIndex: 'taxRate',
            width: 120,
            ellipsis: true
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ],
        precolumns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },

          {
            title: '费用大类',
            align: 'center',
            dataIndex: 'bigCategory',
            width: 120,
            ellipsis: true,
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['bigCategory'], text + '')
              }
            }
          },
          {
            title: '费用小类',
            align: 'center',
            dataIndex: 'smallCategory',
            width: 120,
            ellipsis: true,
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['smallCategory'], text + '')
              }
            }
          },
          {
            title: '发票类型',
            align: 'center',
            dataIndex: 'isSpecial',
            width: 120,
            ellipsis: true,
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['isSpecial'], text + '')
              }
            }
          },
          {
            title: '报销金额（元）',
            align: 'center',
            dataIndex: 'amount',
            width: 120,
            ellipsis: true
          },
          {
            title: '税费金额（元）',
            align: 'center',
            dataIndex: 'taxation',
            width: 120,
            ellipsis: true
          },
          {
            title: '未税金额（元）',
            align: 'center',
            dataIndex: 'untaxedAmount',
            width: 120,
            ellipsis: true
          },
          {
            title: '税率（%）',
            align: 'center',
            dataIndex: 'taxRate',
            width: 120,
            ellipsis: true
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ],
        salaryColumns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },

          {
            title: '工资福利大类',
            align: 'center',
            dataIndex: 'bigCategory',
            width: 200,
            ellipsis: true,
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['bigCategory'], text + '')
              }
            }
          },
          {
            title: '工资福利小类',
            align: 'center',
            dataIndex: 'smallCategory',
            width: 200,
            ellipsis: true,
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['smallCategory'], text + '')
              }
            }
          },
          {
            title: '发票类型',
            align: 'center',
            dataIndex: 'isSpecial',
            width: 120,
            ellipsis: true,
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['isSpecial'], text + '')
              }
            }
          },
          {
            title: '报销金额(元)',
            align: 'center',
            dataIndex: 'amount',
            width: 120,
            ellipsis: true
          },
          {
            title: '税费金额(元)',
            align: 'center',
            dataIndex: 'taxation',
            width: 120,
            ellipsis: true
          },
          {
            title: '未税金额(元)',
            align: 'center',
            dataIndex: 'untaxedAmount',
            width: 120,
            ellipsis: true
          },
          {
            title: '税率（%）',
            align: 'center',
            dataIndex: 'taxRate',
            width: 120,
            ellipsis: true
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ],
        chargedLoanColumns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '冲账借款单据',
            align: 'center',
            dataIndex: 'relBillId',
            scopedSlots: { customRender: 'relBillId' }
          },
          {
            title: '借款金额(元)',
            align: 'center',
            dataIndex: 'borrowLoanAmount'
          },
          {
            title: '已还金额(元)',
            align: 'center',
            dataIndex: 'borrowOnloanAmount'
          },
          {
            title: '本次冲账金额(元)',
            align: 'center',
            dataIndex: 'chargedAmount'
          },
          {
            title: '剩余未冲账金额(元)',
            align: 'center',
            dataIndex: 'unChargedAmount'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ],
        chargedPayColumns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '冲账付款单单据',
            align: 'center',
            dataIndex: 'relBillId',
            scopedSlots: { customRender: 'relBillId' }
          },
          {
            title: '预付款金额(元)',
            align: 'center',
            dataIndex: 'payPayableAmount'
          },
          {
            title: '已冲账金额(元)',
            align: 'center',
            dataIndex: 'payOnChargedAmount'
          },
          {
            title: '本次冲账金额(元)',
            align: 'center',
            dataIndex: 'chargedAmount'
          },
          {
            title: '剩余未冲账金额(元)',
            align: 'center',
            dataIndex: 'unChargedAmount'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ]
      }
    },
    computed: {
      formDisabled() {
        if (this.formBpm === true) {
          if (this.formData.disabled === false) {
            return false
          }
          return true
        }
        return this.disabled
      },
      showFlowSubmitButton() {
        if (this.formBpm === true) {
          if (this.formData.disabled === false) {
            return true
          }
        }
        return false
      }
    },
    created () {
       // 备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
      // 如果是流程中表单，则需要加载流程表单data
      this.showFlowData();
      // 加载数据字典信息
      this.initDictConfig();
      if (this.formDisabled) {
        this.columns.pop()
        this.precolumns.pop()
        this.salaryColumns.pop()
      }
      this.customKey = 'columns'
      this.otherKey = 'salaryColumns'
    },
    methods: {
      loadBillDetail(text) {
        if (!text) {
          return ''
        } else {
          return this.model.relBillType == '1' ? filterMultiDictText(this.dictOptions['relLoanBillId'], text + '') : filterMultiDictText(this.dictOptions['relPayBillId'], text + '')
        }
      },
      loadProjectDetail(text) {
        if (!text) {
          return ''
        } else {
          return filterMultiDictText(this.dictOptions['projectId'], text + '')
        }
      },
      goProjectDetail(record) {
        const that = this
        this.$nextTick(() => {
          getAction(this.url.queryProjectReportById, { id: record.projectId }).then((res) => {
            if (res.success) {
              const model = res.result
              that.$refs.projectReport.getDetail(model);
              that.$refs.projectReport.title = '项目一览表';
            }
          })
        })
      },
      getProjectContract(data) {
        if (data) {
          if (this.model.purchaseyFeeInfo.contractPaymentId) {
            this.$set(this.model.purchaseyFeeInfo, 'contractPaymentId', null);
            this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', 0);
          }
          if (this.model.purchaseyFeeInfo.relContractId) {
            getAction(this.url.queryContractById, { id: this.model.purchaseyFeeInfo.relContractId }).then((res) => {
              if (res.success) {
                let resData = res.result;
                if (resData) {
                  this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', resData.receivablesPaymentMoney);
                  this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', resData.realCollectionPaymentMoney);
                  let deductMoney = resData.deductMoney;
                  let unpaymentAmount = 0;
                  if (deductMoney != null && deductMoney != '') {
                    unpaymentAmount = (resData.receivablesPaymentMoney.toFixed(2) - resData.realCollectionPaymentMoney.toFixed(2) - deductMoney.toFixed(2)).toFixed(2)
                  } else {
                    unpaymentAmount = (resData.receivablesPaymentMoney.toFixed(2) - resData.realCollectionPaymentMoney.toFixed(2)).toFixed(2)
                  }
                  this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', unpaymentAmount);
                }
              }
            })
          } else {
            this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', 0);
          }
        }
      },
      // 选择采购类项目
      selectProject(data) {
        if (data) {
          if (data.choseObj && data.choseObj.length) {
            this.$set(this.model.purchaseyFeeInfo, 'projectCode', data.choseObj[0].finalNo);
            this.$set(this.model.purchaseyFeeInfo, 'performanceAttributionYear', data.choseObj[0].year);
          } else {
            this.$set(this.model.purchaseyFeeInfo, 'projectCode', '');
            this.$set(this.model.purchaseyFeeInfo, 'performanceAttributionYear', '');
            this.$set(this.model.purchaseyFeeInfo, 'relContractId', '');
            this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'contractTotalAmount', '');
            this.$set(this.model.purchaseyFeeInfo, 'contractActualCollectAmount', '');
          }
          if (this.model.purchaseyFeeInfo.relContractId) {
            this.$set(this.model.purchaseyFeeInfo, 'relContractId', '');
            this.$set(this.model.purchaseyFeeInfo, 'contractPaymentId', '');
            this.$set(this.model.purchaseyFeeInfo, 'paymentProportion', '');
            this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', 0);
            // 切换项目清空收款信息：accountName、bankName、accountNo
            this.$set(this.model, 'accountName', '');
            this.$set(this.model, 'bankName', '');
            this.$set(this.model, 'accountNo', '');
            this.$set(this.model, 'cnapsCode', '');
          }
          if (this.model.purchaseyFeeInfo.projectId) {
            getAction(this.url.queryContractByProjectId, { 'xmmc': this.model.purchaseyFeeInfo.projectId, 'htlx': '1', 'status': '2,3' }).then((res) => {
              if (res.success) {
                  let resResult = res.result;
                  if (resResult.records) {
                    let contractInfo = resResult.records[0]
                    this.$set(this.model.purchaseyFeeInfo, 'contractTotalAmount', contractInfo.receivablesPaymentMoney);
                    this.$set(this.model.purchaseyFeeInfo, 'contractActualCollectAmount', contractInfo.realCollectionPaymentMoney);
                  }
              }
            })
          } else {
            this.$set(this.model.purchaseyFeeInfo, 'contractTotalAmount', null);
            this.$set(this.model.purchaseyFeeInfo, 'contractActualCollectAmount', null);
          }
        }
      },
      getCheckoutInfo(data) {
        if (data.length > 0) {
          let paymentAmount = 0;
          let paymentTotalAmount = 0;
          for (var i = 0; i < data.length; i++) {
            paymentTotalAmount += data[i].realCollectionPaymentMoney;
            paymentAmount += data[i].paymentMoney;
          }
          this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', paymentAmount.toFixed(2));
          this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', paymentTotalAmount.toFixed(2));
          this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', (paymentAmount - paymentTotalAmount).toFixed(2));
        } else {
          this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', 0);
          this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', 0);
          this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', 0);
        }
      },
      // 切换公司
      selectApplicant(data) {
        if (data) {
          if (this.model.relBillType) {
            this.$set(this.model, 'relBillType', null);
            this.$set(this.model, 'relBillId', '');
            this.$set(this.model, 'borrowPayAmount', '');
            this.$set(this.model, 'borrowOnloanAmount', '');
            this.$set(this.model, 'borrowLoanAmount', '');
            this.$set(this.model, 'borrowUnloanAmount', '');
            this.$set(this.model, 'payApplicant', '');
            this.$set(this.model, 'payPayeeName', '');
            this.$set(this.model, 'payPayableAmount', '');
            this.$set(this.model, 'payUnChargedAmount', '');
            this.$set(this.model, 'payOnChargedAmount', '');
            this.$set(this.model, 'payPaidAmount', '');
            this.$set(this.model, 'payDeductionAmount', '');
            this.$set(this.model, 'depositRemittanceAmount', '');
            this.$set(this.model, 'depositReturnAmount', '');
            this.$set(this.model, 'depositUnreturnAmount', '');
            this.$set(this.model, 'depositServiceCharge', '');
            this.$set(this.model, 'depositInterestAmount', '');
            this.$set(this.model, 'chargedInfoList', []);
          }
          // 采购类
          if (this.model.feeCategory == '0') {
            this.$set(this.model, 'salaryFeeInfoList', []);
            this.$set(this.model, 'accumulateAmount', 0);
          } else if (this.model.feeCategory == '1') {
            this.$set(this.model, 'purchaseyFeeInfo', {});
            this.$set(this.model.purchaseyFeeInfo, 'projectCode', '');
            this.$set(this.model.purchaseyFeeInfo, 'projectId', '');
            this.$set(this.model.purchaseyFeeInfo, 'relContractId', '');
            this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'contractTotalAmount', '');
            this.$set(this.model.purchaseyFeeInfo, 'contractActualCollectAmount', '');
            this.$set(this.model, 'accumulateAmount', 0);
          } else if (this.model.feeCategory == '2') {
            this.$set(this.model, 'dailyFeeInfoList', []);
            this.$set(this.model, 'accumulateAmount', 0);
          }
        }
      },
      // 切换转账类型
      radioTransferType(data) {
        if (data) {
          if (this.model.accountName) {
            this.$set(this.model, 'accountName', null);
            this.$set(this.model, 'bankName', '');
            this.$set(this.model, 'accountNo', '');
            this.$set(this.model, 'cnapsCode', '');
          }
        }
      },

       // 加载穿透表单
      goDetail(id) {
        if (this.model.relBillType == '1') {
          this.$refs.loanBillPenetrate.initData(id);
          this.$refs.loanBillPenetrate.visible = true;
        } else if (this.model.relBillType == '2') {
          this.$refs.paymentBillPenetrate.initData(id);
          this.$refs.paymentBillPenetrate.visible = true;
        } else if (this.model.relBillType == '3') {
          this.$refs.depositBillPenetrate.initData(id);
          this.$refs.depositBillPenetrate.visible = true;
        }
      },
      goPurchaseContractDetail(id) {
        this.$refs.erpPurchaseContractPenetrate.initData(id);
        this.$refs.erpPurchaseContractPenetrate.visible = true;
      },
      goContractDetail(id) {
        this.$refs.erpContractManagerPenetrate.initData(id);
        this.$refs.erpContractManagerPenetrate.visible = true;
      },
      // 选择人员
      selectAccountName() {
        let accountName = this.model.accountName
        getAction(this.url.queryFileById, { id: accountName }).then(res => {
          if (res.success) {
            let result = res.result
            this.$set(this.model, 'bankName', result.bankName);
            this.$set(this.model, 'accountNo', result.bankCard);
            this.$set(this.model, 'cnapsCode', result.cnapsCode);
          }
        })
      },
      // 选择单位
      selectCustomer(data) {
        if (data) {
          this.$set(this.model, 'bankName', data[0].bankName);
          this.$set(this.model, 'accountNo', data[0].bankAccountNo);
          this.$set(this.model, 'cnapsCode', data[0].cnapsCode);
        }
      },
      // 修改大类，清空小类
      modifyCategory(data) {
        if (data) {
          if (this.model.salaryFeeInfo.smallCategory) {
            this.$set(this.model.salaryFeeInfo, 'smallCategory', null);
          }
        }
      },
      selectTeam(data) {
        this.model.teamYear = data[0].tdnd;
        // 工资福利类
        if (this.model.feeCategory == '1') {
          if (this.model.purchaseyFeeInfo.relContractId) {
            this.model.purchaseyFeeInfo = {};
          }
          // 费用类
        } else if (this.model.feeCategory == '2') {
          if (this.model.dailyFeeInfoList) {
              this.model.dailyFeeInfoList = [];
          }
        }
        // 清空冲账单据信息
        this.selectApplicant('1');
      },
      // 获取合同详情
      getContract(data) {
        if (data) {
          // //切换合同带出公司名称到收款户名 ： 条件为：结算方式为转账，转账类型为供应商
          if (this.model.settleType == '0' && this.model.transferType == '2') {
            this.$set(this.model, 'accountName', data[0].supplyCompanName)

            let customerId = data[0].supplyCompanName
            getAction('/api/erp/purchase/supplier/erpPurchaseSupplier/queryById', { id: customerId }).then((res) => {
              if (res.success) {
                // 带出收款方开户行
                this.$set(this.model, 'bankName', res.result.bankName)
                // 带出收款方账户
                this.$set(this.model, 'accountNo', res.result.bankAccountNo)
                this.$set(this.model, 'cnapsCode', res.result.cnapsCode)
              }
            })
          }
          this.$set(this.model.purchaseyFeeInfo, 'teamId', data[0].teamId);
          this.$set(this.model.purchaseyFeeInfo, 'isSpecial', data[0].invoiceCategory);
          this.isSpecial(2);
          if (this.model.purchaseyFeeInfo.contractPaymentId) {
            this.$set(this.model.purchaseyFeeInfo, 'contractPaymentId', null);
            this.$set(this.model.purchaseyFeeInfo, 'paymentProportion', null);
            this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', null);
            this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', 0);
          }
          if (this.model.purchaseyFeeInfo.relContractId) {
            getAction(this.url.queryPurchaseContractById, { id: this.model.purchaseyFeeInfo.relContractId }).then((res) => {
              if (res.success) {
                let resData = res.result;
                if (resData) {
                  this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', resData.totalAmount);
                  this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', resData.practicalPaidAmount);
                  let deductMoney = resData.deductCountAmount;
                  let unpaymentAmount = 0;
                  if (deductMoney != null && deductMoney != '') {
                    unpaymentAmount = (resData.totalAmount.toFixed(2) - resData.practicalPaidAmount.toFixed(2) - deductMoney.toFixed(2)).toFixed(2)
                  } else {
                    unpaymentAmount = (resData.totalAmount.toFixed(2) - resData.practicalPaidAmount.toFixed(2)).toFixed(2)
                  }
                  this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', unpaymentAmount);
                }
              }
            })
          } else {
            this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', 0);
            this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', 0);
          }
        }
      },
      getContractPayment(data) {
        if (data.length > 0) {
          let paymentAmount = 0;
          let paymentTotalAmount = 0;
          for (var i = 0; i < data.length; i++) {
            paymentAmount += data[i].paymentAmount;
            paymentTotalAmount += data[i].paymentTotalAmount;
          }
          this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', paymentAmount.toFixed(2));
          this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', paymentTotalAmount.toFixed(2));
          this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', (paymentAmount - paymentTotalAmount).toFixed(2));
        } else {
          this.$set(this.model.purchaseyFeeInfo, 'paymentAmount', 0);
          this.$set(this.model.purchaseyFeeInfo, 'collectedAmount', 0);
          this.$set(this.model.purchaseyFeeInfo, 'unpaymentAmount', 0);
        }
        this.isSpecial(2);
      },
      // 修改
      handleChange(value) {
        this.provisionSmallList = []
        this.$set(this.model.purchaseyFeeInfo, 'smallCategory', undefined);
        this.$refs['form'].clearValidate('purchaseyFeeInfo.smallCategory');
        if (value) {
          this.findProvisionSmallList(value)
        }
      },
      modifySmallCategory(data){
        if(data){
          let res=this.provisionSmallList.filter(item=>item.id==data);
          if(res[0].checkPosition){
            this.$set(this.model.purchaseyFeeInfo,"checkPosition",res[0].checkPosition);
          }else{
            this.$set(this.model.purchaseyFeeInfo,"checkPosition",'');
          }

        }
      },
      // 大类
      findProvisionBroadList() {
        const that = this
        that.provisionBroadList = []
        getAction(this.url.queryProvisionBroadList).then(res => {
          if (res.success) {
            res.result.forEach((res) => {
              that.provisionBroadList.push({ 'id': res.id, 'categoryName': res.categoryName, 'checkPosition': res.checkPosition })
            })
          } else {
            that.$message.warning(res.message)
          }
        })
      },
      // 小类
      findProvisionSmallList(value) {
        const that = this
        const parentId = value
        that.provisionSmallList = [];
        getAction(this.url.queryProvisionSmallList, { parentId }).then(res => {
          if (res.success) {
            res.result.forEach((res) => {
              that.provisionSmallList.push({ 'id': res.id, 'categoryName': res.categoryName, 'checkPosition': res.checkPosition })
            })
          } else {
            that.$message.warning(res.message)
          }
        })
      },
      // 筛选
      filterOption(input, option) {
        return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        );
      },
      // 切换结算方式
      radioSettleType(ops) {
        if (ops == '0') { // 转账
          // ERP迭代16.7 ： 当“结算方式”选择转账后，“转账类型”默认为供应商
          if (this.model.feeCategory == '1') {
            this.$set(this.model, 'transferType', '2');
            // 非项目付款合同选择转账才能带出供方信息的公司名称
            if (!this.model.purchaseyFeeInfo.projectId && this.model.purchaseyFeeInfo.relContractId) {
              getAction(this.url.queryPurchaseContractById, { id: this.model.purchaseyFeeInfo.relContractId }).then((res) => {
                if (res.success) {
                  // 迭代16.7：“收款户名”从采购合同中带出供方信息的“公司名称”
                  this.$set(this.model, 'accountName', res.result.supplyCompanName)
                  let customerId = res.result.supplyCompanName
                  getAction('/api/erp/purchase/supplier/erpPurchaseSupplier/queryById', { id: customerId }).then((res) => {
                    if (res.success) {
                      // 带出收款方开户行
                      this.$set(this.model, 'bankName', res.result.bankName)
                      this.$set(this.model, 'cnapsCode', res.result.cnapsCode)
                      // 带出收款方账户
                      this.$set(this.model, 'accountNo', res.result.bankAccountNo)
                    }
                  })
                }
              })
            }
          } else {
            this.$set(this.model, 'transferType', null);
          }
          // this.$set(this.model, 'transferType', '2');
          // ---------------------end----------------------------
          // this.$refs["form"].clearValidate('relBillId');
          // this.$set(this.model, 'relBillType',null);
          // this.$set(this.model, 'relBillId', '');
          // this.$set(this.model, 'borrowPayAmount', '');
          // this.$set(this.model, 'borrowOnloanAmount', '');
          // this.$set(this.model, 'borrowLoanAmount', '');
          // this.$set(this.model, 'borrowUnloanAmount', '');
        } else if (ops == '2') { // 冲账
          this.$set(this.model, 'transferType', null);
          this.$refs['form'].clearValidate('accountName');
          this.$refs['form'].clearValidate('bankName');
          this.$refs['form'].clearValidate('cnapsCode');
          this.$refs['form'].clearValidate('accountNo');
          this.$set(this.model, 'accountName', '');
          this.$set(this.model, 'bankName', '');
          this.$set(this.model, 'cnapsCode', '');
          this.$set(this.model, 'accountNo', '');
        } else {
          // this.$set(this.model, 'relBillType', null);
          // this.$set(this.model, 'relBillId', '');
          // this.$set(this.model, 'borrowPayAmount', '');
          // this.$set(this.model, 'borrowOnloanAmount', '');
          // this.$set(this.model, 'borrowLoanAmount', '');
          // this.$set(this.model, 'borrowUnloanAmount', '');
          this.$set(this.model, 'transferType', null);
          this.$set(this.model, 'accountName', '');
          this.$set(this.model, 'bankName', '');
          this.$set(this.model, 'cnapsCode', '');
          this.$set(this.model, 'accountNo', '');
        }
      },
      // 切换费用类别分类
      radioCategory(item) {
        this.$set(this.model, 'settleType', null)
        this.$set(this.model, 'transferType', null)
        this.$set(this.model, 'bankName', '') // 收款方开户行
        this.$set(this.model, 'cnapsCode', '') // 收款方开户行
				this.$set(this.model, 'accountNo', '') // 收款方银行账户

        this.$set(this.model, 'accumulateAmount', 0);
        this.$set(this.model, 'salaryFeeInfo', {});
        this.$set(this.model, 'salaryFeeInfoList', []);
        this.$set(this.model, 'purchaseyFeeInfo', {});
        this.$set(this.model, 'dailyFeeInfoList', []);
        this.$set(this.model, 'chargedInfoList', []);
        this.$set(this.model, 'isRelProject', '1');
        this.$set(this.model.purchaseyFeeInfo, 'taxation', 0);
        this.$set(this.model.salaryFeeInfo, 'taxation', 0);
        if (this.model.relBillType == '3') {
          this.$set(this.model, 'relBillType', '');
          this.$set(this.model, 'relBillId', '');
          this.$set(this.model, 'depositRemittanceAmount', '');
          this.$set(this.model, 'depositReturnAmount', '');
          this.$set(this.model, 'depositUnreturnAmount', '');
          this.$set(this.model, 'depositServiceCharge', '');
          this.$set(this.model, 'depositInterestAmount', '');
        }
        // 选择采购类重置发票类型
        if (item.value == '1') {
          this.isSpecial('2')
        }
        this.handelCharedAmount()
      },
       // 修改按钮
      radioChange (data) {
        if (data == undefined) {
          this.$set(this.model, 'relBillType', '');
        }
        if (data) {
          this.$set(this.model, 'relBillId', '');
          this.$set(this.model, 'borrowPayAmount', '');
          this.$set(this.model, 'borrowOnloanAmount', '');
          this.$set(this.model, 'borrowLoanAmount', '');
          this.$set(this.model, 'borrowUnloanAmount', '');
          this.$set(this.model, 'payApplicant', '');
          this.$set(this.model, 'payPayeeName', '');
          this.$set(this.model, 'payPayableAmount', '');
          this.$set(this.model, 'payUnChargedAmount', '');
          this.$set(this.model, 'payOnChargedAmount', '');
          this.$set(this.model, 'payPaidAmount', '');
          this.$set(this.model, 'payDeductionAmount', '');
          this.$set(this.model, 'depositRemittanceAmount', '');
          this.$set(this.model, 'depositReturnAmount', '');
          this.$set(this.model, 'depositUnreturnAmount', '');
          this.$set(this.model, 'depositServiceCharge', '');
          this.$set(this.model, 'depositInterestAmount', '');
          this.$set(this.model, 'chargedInfoList', []);
          this.handelCharedAmount()
        } else {
					this.$set(this.model, 'chargedAmount', '0.00');
					this.$set(this.model, 'chargedInfoList', []);
				}
      },
      // 获取编号
      getBillNo() {
        let that = this;
        getAction(this.url.getBillNo, {}).then((res) => {
          if (res.success) {
            let data = res.result.records || res.result
            this.$set(this.model, 'billNo', data);
            this.$set(this.model, 'bpmBizTitle', this.userInfo().employee.name + '-' + data);
            this.billNoDisabled = true;
          }
        })
      },
      //发票类型
      isSpecialInit(arg){
        if (arg == 2) { // 采购
          if(this.model.purchaseyFeeInfo.isSpecial == 0){ // 普票：税费和税率默认为0，发起人不可编辑和修改（流程中也不可修改）
            // this.$set(this.model.purchaseyFeeInfo, 'taxation',0);
            // this.$set(this.model.purchaseyFeeInfo, 'taxRate',0);
            this.$delete(this.validatorRules.purchaseyFeeInfo, 'taxation');
            this.$delete(this.validatorRules.purchaseyFeeInfo, 'taxRate');
            this.$refs.form.clearValidate('purchaseyFeeInfo.taxation');
            this.$refs.form.clearValidate('purchaseyFeeInfo.taxRate');
            this.isSpecialDisabled=true;
            this.isTaxRateDisabled=true;
          }else if (this.model.purchaseyFeeInfo.isSpecial == 1){ // 专票：税费和税率为必填，发起人可编辑和修改 （税率计算公式：税费金额/未税金额取整，流程中都可修改）
            this.$refs.form.clearValidate('purchaseyFeeInfo.taxation');
            // this.$set(this.model.purchaseyFeeInfo, 'taxation',null);
            // this.$set(this.model.purchaseyFeeInfo, 'taxRate',null);
            this.$set(this.validatorRules.purchaseyFeeInfo, 'taxRate', [{ required: true, message: '请输入正确的税率!'}]);
            this.$set(this.validatorRules.purchaseyFeeInfo, 'taxation', [{ required: true,pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}]);
            this.isSpecialDisabled=false;
            this.isTaxRateDisabled=false;
          } else { // 其他或者不填：税费金额必填默认为0，发起人可修改，税率默认为0，发起人不可编辑和修改（流程中可以修改税费金额，不可修改税率）
            // this.$set(this.model.purchaseyFeeInfo, 'taxation',0);
            // this.$set(this.model.purchaseyFeeInfo, 'taxRate',0);
            this.$delete(this.validatorRules.purchaseyFeeInfo, 'taxRate');
            this.$set(this.validatorRules.purchaseyFeeInfo, 'taxation', [{ required: true,pattern: /^(([0-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}]);
            this.$refs.form.clearValidate('purchaseyFeeInfo.taxation');
            this.$refs.form.clearValidate('purchaseyFeeInfo.taxRate');
            this.isSpecialDisabled=false;
            this.isTaxRateDisabled=true;
          }
        }
      },
      // 发票类型
      isSpecial(arg) {
        if (arg == 1) { // 工资福利
          // if(this.model.salaryFeeInfo.isSpecial!=1){//不是专票
              // this.$set(this.model.salaryFeeInfo, 'taxation',0);
              // this.isSpecialDisabled=true;
              // this.inputAmount(1);
              // this.$refs.form.clearValidate('salaryFeeInfo.taxation');
              // this.$set(this.validatorRules.salaryFeeInfo, 'taxation', [{ required: false,pattern: /^(([1-9][0-9]*|0)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}]);
          // }else{
            // this.$refs.form.clearValidate('salaryFeeInfo.taxation');
            // this.$set(this.validatorRules.salaryFeeInfo, 'taxation', [{ required: true,pattern: /^(([1-9][0-9]*|0)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}]);
            // this.isSpecialDisabled=false;
          // }
        } else if (arg == 2) { // 采购
          if(this.model.purchaseyFeeInfo.isSpecial == '0'){ // 普票：税费和税率默认为0，发起人不可编辑和修改（流程中也不可修改）
            this.$set(this.model.purchaseyFeeInfo, 'taxation',0);
            this.$set(this.model.purchaseyFeeInfo, 'taxRate',0);
            this.$delete(this.validatorRules.purchaseyFeeInfo, 'taxation');
            this.$delete(this.validatorRules.purchaseyFeeInfo, 'taxRate');
            this.$refs.form.clearValidate('purchaseyFeeInfo.taxation');
            this.$refs.form.clearValidate('purchaseyFeeInfo.taxRate');
            this.isSpecialDisabled=true;
            this.isTaxRateDisabled=true;
          }else if (this.model.purchaseyFeeInfo.isSpecial == '1'){ // 专票：税费和税率为必填，发起人可编辑和修改 （税率计算公式：税费金额/未税金额取整，流程中都可修改）
            this.$refs.form.clearValidate('purchaseyFeeInfo.taxation');
            this.$set(this.model.purchaseyFeeInfo, 'taxation',null);
            this.$set(this.model.purchaseyFeeInfo, 'taxRate',null);
            this.$set(this.validatorRules.purchaseyFeeInfo, 'taxRate', [{ required: true, message: '请输入正确的税率!'}]);
            this.$set(this.validatorRules.purchaseyFeeInfo, 'taxation', [{ required: true,pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}]);
            this.isSpecialDisabled=false;
            this.isTaxRateDisabled=false;
          } else { // 其他或者不填：税费金额必填默认为0，发起人可修改，税率默认为0，发起人不可编辑和修改（流程中可以修改税费金额，不可修改税率）
            this.$set(this.model.purchaseyFeeInfo, 'taxation',0);
            this.$set(this.model.purchaseyFeeInfo, 'taxRate',0);
            this.$delete(this.validatorRules.purchaseyFeeInfo, 'taxRate');
            this.$set(this.validatorRules.purchaseyFeeInfo, 'taxation', [{ required: true,pattern: /^(([0-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}]);
            this.$refs.form.clearValidate('purchaseyFeeInfo.taxRate');
            this.isSpecialDisabled=false;
            this.isTaxRateDisabled=true;
          }

          // if (this.model.purchaseyFeeInfo.isSpecial != 1) { // 不是专票
          //     this.$set(this.model.purchaseyFeeInfo, 'taxation', 0);
          //     this.isSpecialDisabled = true;
          //     this.$refs.form.clearValidate('purchaseyFeeInfo.taxation');
          //     this.$set(this.validatorRules.purchaseyFeeInfo, 'taxation', [{ required: false, pattern: /^(([1-9][0-9]*|0)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' }]);
          // } else {
          //   this.$refs.form.clearValidate('purchaseyFeeInfo.taxation');
          //   this.$set(this.validatorRules.purchaseyFeeInfo, 'taxation', [{ required: true, pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' }]);
          //   this.isSpecialDisabled = false;
          // }
          this.inputAmount(2);
        }
      },
      // 关联单号
      relBillData(data) {
        let id = this.model.relBillId;
        if (this.model.relBillType == '1') { // 借款单
          getAction('/api/erp/finance/borrow/erpFinanceLoanBill/queryById', { 'id': id }).then((res) => {
            if (res.success) {
                let data = res.result;
                let loanAmount = data.amount;// 借款金额
                let onloanAmount = data.repaymentAmount + data.travelReimbursementAmount + data.expenseReimbursementAmount;// 已还金额
                let unloanAmount = loanAmount - onloanAmount;
                let amount = 0;// 报销金额
                if (this.model.feeCategory == '0') {
                  // amount=this.model.salaryFeeInfo.amount;
                  amount = this.model.accumulateAmount;
                } else if (this.model.feeCategory == '1') {
                  amount = this.model.purchaseyFeeInfo.amount;
                } else if (this.model.feeCategory == '2') {
                  this.model.dailyFeeInfoList.forEach(item => {
                    amount += item.amount;
                  })
                }
                let loadPayAmount = (amount - unloanAmount).toFixed(2);
                this.$set(this.model, 'borrowLoanAmount', loanAmount);
                this.$set(this.model, 'borrowOnloanAmount', onloanAmount);
                this.$set(this.model, 'borrowUnloanAmount', unloanAmount);
                if (loadPayAmount > 0) {
                  this.$set(this.model, 'borrowPayAmount', loadPayAmount);
                } else {
                  this.$set(this.model, 'borrowPayAmount', 0);
                }
            }
          })
        } else if (this.model.relBillType == '2') { // 付款单
          getAction('/api/erp/finance/payment/erpFinancePaymentSlipFeeDetail/queryBillInfoByBillId', { 'billId': id }).then((res) => {
            if (res.success) {
                let resResult = res.result.records[0];
                // if(resResult.projectFeeType!='1'){
                //   this.$message.error('选择的付款单不是预付款的申请单');
                //   this.$set(this.model,'relBillId','');
                //   this.$set(this.model,'payPayableAmount','');
                //   this.$set(this.model,'payPaidAmount','');
                //   this.$set(this.model,'payDeductionAmount','');
                //   this.$set(this.model,'payApplicant',null);
                //   this.$set(this.model,'payPayeeName',null);
                //   return;
                // }
                // let payApplicant=data[0].applicant;//申请公司
                // let payPayeeName=data[0].payeeName//收款单位
                // let payAmount=resResult.currentPaidAmount;//支付金额
                let payPayableAmount = resResult.currentPaidAmount;// 应付金额
                let unChargedAmount = resResult.unChargedAmount;// 未冲账金额
                let onChargedAmount = resResult.onChargedAmount;// 冲账金额
                // let payPaidAmount=resResult.currentPaidAmount;//本次支付金额
                // let payDeductionAmount=resResult.currentDeductionAmount;//本次扣款金额
                // this.$set(this.model,'payPayableAmount',payPayableAmount);
                // this.$set(this.model,'payPaidAmount',payPaidAmount);
                // this.$set(this.model,'payDeductionAmount',payDeductionAmount);
                // this.$set(this.model,'payApplicant',payApplicant);
                // this.$set(this.model,'payPayeeName',payPayeeName);
                this.$set(this.model, 'payUnChargedAmount', unChargedAmount);
                this.$set(this.model, 'payOnChargedAmount', onChargedAmount);
                this.$set(this.model, 'payPayableAmount', payPayableAmount);
            }
          })
        } else if (this.model.relBillType == '3') { // 保证金
            let depositRemittanceAmount = data[0].remittanceAmount;// 保证金总额
            let depositReturnAmount = data[0].returnAmount// 归还总额
            let depositServiceCharge = data[0].serviceCharge;// 服务费金额
            let depositInterestAmount = data[0].interestAmount;// 利息金额
            let depositUnreturnAmount = data[0].unreturnAmount;// 未还金额
            this.$set(this.model, 'depositRemittanceAmount', depositRemittanceAmount);
            this.$set(this.model, 'depositReturnAmount', depositReturnAmount);
            this.$set(this.model, 'depositUnreturnAmount', depositUnreturnAmount);
            this.$set(this.model, 'depositServiceCharge', depositServiceCharge);
            this.$set(this.model, 'depositInterestAmount', depositInterestAmount);
        }
      },
      // 输入报销金额
       inputAmount(arg) {
      //   if(arg==1){//工资福利

      //     if(this.model.borrowPayAmount!=undefined && this.model.borrowPayAmount!=null){
      //       // 报销金额 - 未还金额
      //       // let borrowPayAmount=(this.model.salaryFeeInfo.amount-this.model.borrowUnloanAmount).toFixed(2);
      //       let borrowPayAmount=(this.model.accumulateAmount-this.model.borrowUnloanAmount).toFixed(2);
      //       if(borrowPayAmount>0){
      //         this.$set(this.model,'borrowPayAmount',borrowPayAmount);
      //       }else{
      //         this.$set(this.model,'borrowPayAmount',0);
      //       }
      //     }
      //     // taxation 税费金额=0
      //     // if(this.model.salaryFeeInfo.amount && (this.model.salaryFeeInfo.taxation || this.model.salaryFeeInfo.taxation==0)){
      //     //   // 未税金额 = 报销金额 - 税费金额
      //     //   this.model.salaryFeeInfo.untaxedAmount=(this.model.salaryFeeInfo.amount-this.model.salaryFeeInfo.taxation).toFixed(2);
      //     // }
         if (arg == 2) { // 采购
          // if(this.model.borrowPayAmount!=undefined && this.model.borrowPayAmount!=null){
          //   let borrowPayAmount=(this.model.purchaseyFeeInfo.amount-this.model.borrowUnloanAmount).toFixed(2);
          //   if(borrowPayAmount>0){
          //     this.$set(this.model,'borrowPayAmount',borrowPayAmount);
          //   }else{
          //     this.$set(this.model,'borrowPayAmount',0);
          //   }
          // }
          // 判断当有值的
          if(this.model.purchaseyFeeInfo.taxation === null || this.model.purchaseyFeeInfo.taxation === '' || this.model.purchaseyFeeInfo.taxation === undefined){
            this.$set(this.model.purchaseyFeeInfo,'untaxedAmount', null);
            return false
          }
          if (this.model.purchaseyFeeInfo.amount && (this.model.purchaseyFeeInfo.taxation || this.model.purchaseyFeeInfo.taxation == 0)) {
            let untaxedAmount = (this.model.purchaseyFeeInfo.amount - this.model.purchaseyFeeInfo.taxation).toFixed(2);
            if (untaxedAmount > 0) {
              this.$set(this.model.purchaseyFeeInfo, 'untaxedAmount', untaxedAmount);
              if (this.model.purchaseyFeeInfo.isSpecial == 1) {
                this.$set(this.model.purchaseyFeeInfo, 'taxRate', (this.model.purchaseyFeeInfo.taxation / this.model.purchaseyFeeInfo.untaxedAmount * 100).toFixed(0));
              } else {
                this.$set(this.model.purchaseyFeeInfo, 'taxRate',0);
              }
            } else {
              this.$set(this.model.purchaseyFeeInfo, 'untaxedAmount', 0);
              this.$set(this.model.purchaseyFeeInfo, 'taxRate', 0);
            }
          }
          // 累计报销金额
          if (this.model.purchaseyFeeInfo.amount) {
            this.$set(this.model, 'accumulateAmount', this.model.purchaseyFeeInfo.amount.toFixed(2));
          }
      //   }else if(arg==3){//费用
      //      if(this.model.borrowPayAmount!=undefined && this.model.borrowPayAmount!=null){
      //       let dailyFeeInfoList=this.model.dailyFeeInfoList;
      //       let amount=0;
      //       dailyFeeInfoList.forEach(dailyFeeInfo=>{
      //         if(dailyFeeInfo.bigCategory=="A01A03A16"){
      //           amount+=dailyFeeInfo.untaxedAmount;
      //         }else{
      //           amount+=dailyFeeInfo.amount;
      //         }
      //       })
      //       let borrowPayAmount=(amount-this.model.borrowUnloanAmount).toFixed(2);
      //       if(borrowPayAmount>0){
      //         this.$set(this.model,'borrowPayAmount',borrowPayAmount);
      //       }else{
      //         this.$set(this.model,'borrowPayAmount',0);
      //       }
      //       // 累计报销金额
      //       this.$set(this.model,'accumulateAmount',parseFloat(amount).toFixed(2));
      //     }
         }
       },
      // 判断是否付款
      isPay() {
        if (this.model.isPay == 0) { // 未付款
          this.$set(this.model, 'settleType', null);
          this.$set(this.model, 'relBillType', null);
          this.$set(this.model, 'payAmount', 0);
          this.isPayDisabled = true;
          this.$set(this.validatorRules, 'relBillType', [{ required: true, message: '请选择冲账类型!' } ]);
        } else {
          this.$set(this.model, 'settleType', null);
          this.$set(this.model, 'relBillType', null);
          this.radioSettleType(null);
          this.isPayDisabled = false;
          this.$set(this.validatorRules, 'relBillType', [{ required: false, message: '请选择冲账类型!' } ]);
        }
      },
      // 加载数据字典信息
      initDictConfig() {
        initDictOptions('erp_omc_team_manager,alias_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'teamId', res.result)
          }
        })
        initDictOptions('erp_finance_loan_bill,bill_no,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'relLoanBillId', res.result)
          }
        })
        initDictOptions('erp_finance_payment_slip,bill_no,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'relPayBillId', res.result)
          }
        })
        initDictOptions('tdnd_type').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'teamYear', res.result)
          }
        })
        initDictOptions('sys_category,name,code').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'bigCategory', res.result)
          }
        })
        initDictOptions('sys_category,name,code').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'smallCategory', res.result)
          }
        })
        initDictOptions('cost_invoice_type').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'isSpecial', res.result)
          }
        })
        initDictOptions('yjgsnd').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'performanceAttributionYear', res.result)
          }
        })
        initDictOptions('erp_omc_project,project_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'projectId', res.result)
          }
        })
        initDictOptions('erp_omc_project_task,category_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'taskCategory', res.result)
          }
        })
        initDictOptions('erp_omc_contract_manager_final,htmc,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'relContractId', res.result)
          }
        })
        initDictOptions('erp_omc_team_manager,alias_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'teamManager', res.result)
          }
        })
      },
      //子表新增
    handleAdd() {
      let flag=this.model.isRelProject=="1"?true:false;
      this.$refs.dailyFee.add(flag);
      this.$refs.dailyFee.title = '新增';
      this.$refs.dailyFee.disableSubmit = false;
    },
    // 子表编辑
    handleEdit(record) {
      let flag = this.model.isRelProject == '1';
      this.$refs.dailyFee.edit(record, flag);
      this.$refs.dailyFee.title = '修改';
      this.$refs.dailyFee.disableSubmit = false;
    },
    // 子表复制行
    handleCopy(record) {
      let model = Object.assign({}, record);
      model.id = parseInt(Math.random() * 1000000000000);
      this.model.dailyFeeInfoList.push(JSON.parse(JSON.stringify(model)))
      // 计算总金额
      let accumulateAmount = 0
      this.model.dailyFeeInfoList.forEach(dailyFeeInfo => {
        // if(dailyFeeInfo.bigCategory=="A01A03A16"){
        //   accumulateAmount+=parseFloat(dailyFeeInfo.untaxedAmount);
        // }else{
          accumulateAmount += dailyFeeInfo.amount;
       // }
      })
      this.model.accumulateAmount = parseFloat(accumulateAmount).toFixed(2)
    },
    // 子表删除
    handleDelete(id) {
      for (let i = 0; i < this.model.dailyFeeInfoList.length; i++) {
        if (this.model.dailyFeeInfoList[i].id == id) {
          this.model.dailyFeeInfoList.splice(i, 1);
        }
      }
     // 计算总金额
     let accumulateAmount = 0
    this.model.dailyFeeInfoList.forEach(dailyFeeInfo => {
      // if(dailyFeeInfo.bigCategory=="A01A03A16"){
      //   accumulateAmount+=parseFloat(dailyFeeInfo.untaxedAmount);
      // }else{
        accumulateAmount += dailyFeeInfo.amount;
     // }
    })
    this.model.accumulateAmount = parseFloat(accumulateAmount).toFixed(2)
      // this.inputAmount(3);
      if (this.model.dailyFeeInfoList.length > 0) {
        this.projectId = this.model.dailyFeeInfoList[0].projectId;
      } else {
        this.$set(this.model, 'relBillType', null);
        this.$set(this.model, 'borrowPayAmount', '');
        this.$set(this.model, 'borrowOnloanAmount', '');
        this.$set(this.model, 'borrowLoanAmount', '');
        this.$set(this.model, 'borrowUnloanAmount', '');
        this.$set(this.model, 'payApplicant', '');
        this.$set(this.model, 'payPayeeName', '');
        this.$set(this.model, 'payPayableAmount', '');
        this.$set(this.model, 'payUnChargedAmount', '');
        this.$set(this.model, 'payOnChargedAmount', '');
        this.$set(this.model, 'payPaidAmount', '');
        this.$set(this.model, 'payDeductionAmount', '');
        this.$set(this.model, 'depositRemittanceAmount', '');
        this.$set(this.model, 'depositReturnAmount', '');
        this.$set(this.model, 'depositServiceCharge', '');
        this.$set(this.model, 'depositInterestAmount', '');
        this.$set(this.model, 'chargedInfoList', []);
        this.handelCharedAmount()
      }
    },
    modalFormOk(data) {
      this.loading = true;
      let flag = true;
      for (let i = 0; i < this.model.dailyFeeInfoList.length; i++) {
        if (this.model.dailyFeeInfoList[i].id == data.id) {
          this.model.dailyFeeInfoList.splice(i, 1, data);
          flag = false;
        }
      }
      if (flag) {
        this.model.dailyFeeInfoList.push(data);
      }
      // 计算总金额
      let accumulateAmount = 0
      this.model.dailyFeeInfoList.forEach(dailyFeeInfo => {
        // if(dailyFeeInfo.bigCategory=="A01A03A16"){
        //   accumulateAmount+=parseFloat(dailyFeeInfo.untaxedAmount);
        // }else{
          accumulateAmount += dailyFeeInfo.amount;
       // }
      })
      this.model.accumulateAmount = parseFloat(accumulateAmount).toFixed(2)
      this.loading = false;
      // this.inputAmount(3);
      if (this.model.dailyFeeInfoList.length > 0) {
        this.projectId = this.model.dailyFeeInfoList[0].projectId;
      }
      // 如果是保证金
      // if(this.model.relBillType=='3'){
      //   //如果项目存在
      //   if(this.projectId){
      //     this.$set(this.model, 'relBillType',null);
      //     this.$set(this.model, 'depositRemittanceAmount', '');
      //     this.$set(this.model, 'depositReturnAmount', '');
      //     this.$set(this.model, 'depositServiceCharge', '');
      //     this.$set(this.model, 'depositInterestAmount', '');
      //   }
      // }
    },
      ...mapGetters(['userInfo']),
      add () {
        // 处理数据为空
        this.$set(this.modelDefault, 'salaryFeeInfo', {});
        this.$set(this.modelDefault, 'salaryFeeInfoList', []);
        this.$set(this.modelDefault, 'purchaseyFeeInfo', {});
        this.$set(this.modelDefault, 'dailyFeeInfoList', []);
        this.$set(this.modelDefault, 'chargedInfoList', []);
        this.$set(this.modelDefault, 'proposer', this.userInfo().empId)
        this.$set(this.modelDefault, 'proposerDeptId', this.userInfo().deptId)
        this.$set(this.modelDefault, 'createTime', moment().format('YYYY-MM-DD HH:mm:ss'))
        this.$set(this.modelDefault, 'purchaseyFeeInfo.taxation', 0);
        this.$set(this.modelDefault, 'salaryFeeInfo.taxation', 0);
        this.edit(this.modelDefault, true);
        this.getBillNo();
        console.log('费用报销1');

      },
      // 获取子表数据
      getChildTableData(url, record) {
        let param = { billId: record.id }
        return new Promise((resolve) => {
          getAction(url, param).then((res) => {
            if (res.success) {
              let data = res.result;
              if (data.records != undefined) {
                resolve(data.records);
              }
              resolve(data);
            } else {
              resolve([])
            }
          })
        })
      },
      async edit (record, flag) {
        this.$refs.form.resetFields();
        this.proposerDeptId = record.proposerDeptId;
        console.log('费用报销2',record);
        if (!flag) {
          // 修改线上审批时，冲账单据不显示
          if (record.relBillType != null && record.relBillType != '') {
            if (record.relBillType == '1' || record.relBillType == '2') {
              let url = this.url.queryCharagedListById
              record.chargedInfoList = await this.getChildTableData(url, record);
            }
          } else {
            record.chargedInfoList = [];
          }
        }
        this.model = await Object.assign({}, record);
        this.model1 = await Object.assign({}, record);
        this.customKey = this.model.isRelProject == '1' ? 'columns' : 'precolumns'
        this.model.accumulateAmount = record.accumulateAmount ? record.accumulateAmount : 0

        if (record.isPay == 0) { // 是否付款
          this.isPayDisabled = true;
          this.$set(this.model, 'payAmount', 0);
          this.$set(this.validatorRules, 'relBillType', [{ required: true, message: '请选择冲账类型!' } ]);
        } else {
          this.$set(this.validatorRules, 'relBillType', []);
        }
        if (this.model.feeCategory == '2') {
          if (this.model.dailyFeeInfoList.length > 0) {
            this.projectId = this.model.dailyFeeInfoList[0].projectId;
          }
        }
        this.isSpecialInit(record.feeCategory == '0' ? 1 : (record.feeCategory == '1' ? 2 : 3));
        if (this.model.purchaseyFeeInfo) {
          this.findProvisionBroadList();
          if (this.model.purchaseyFeeInfo.bigCategory) {
            this.findProvisionSmallList(this.model.purchaseyFeeInfo.bigCategory)
          }
        }
        // 加载关联已开票申请单
        if((this.formDisabled || this.showFlowSubmitButton) && !this.model.relBillNo){
          if(this.model.relBillType=='1'){
            getAction(this.url.qeuryLoanBillById,{id:this.model.relBillId}).then(res=>{
                if(res.success){
                  this.$set(this.model,'relBillNo',res.result.billNo)
                }
            }).catch(e=>{
              console.log(e)
            })
          }else if(this.model.relBillType=='2'){
            getAction(this.url.qeuryPaymentBillById,{id:this.model.relBillId}).then(res=>{
              if(res.success){
                this.$set(this.model,'relBillNo',res.result.billNo)
              }
            }).catch(e=>{
              console.log(e)
            })
          }else if(this.model.relBillType=='3'){
            getAction(this.url.qeuryDepositBillById,{id:this.model.relBillId}).then(res=>{
                this.$set(this.model,'relBillNo',res.result.billNo || '')
            }).catch(e=>{
              console.log(e)
            })
          }
        }

        if ((this.formDisabled || this.showFlowSubmitButton) && !this.model.relContractBillName) {
          if (!this.model.purchaseyFeeInfo) return false // 判断有没有值， 没有值不执行下面的代码
          if (!this.model.purchaseyFeeInfo.projectId) {
            getAction(this.url.queryPurchaseContractById, { id: this.model.purchaseyFeeInfo.relContractId }).then(res => {
              // this.$set(this.model, 'relContractBillName', res.result.contractName)
              this.$set(this.model, 'relContractBillName', res.result.purchaseBill)
            }).catch(e => {
              console.log(e)
            })
          } else {
              getAction(this.url.queryContractById, { id: this.model.purchaseyFeeInfo.relContractId }).then(res => {
                this.$set(this.model, 'relContractBillName', res.result.htmc)
              }).catch(e => {
                console.log(e)
              })
          }
        }
        // 加载关联的项目
        if((this.formDisabled || this.showFlowSubmitButton)&&!this.model.projectName) {
          if(this.model.feeCategory==1 && this.model.purchaseyFeeInfo.projectId){
            getAction(this.url.queryProjectReportById,{id:this.model.purchaseyFeeInfo.projectId}).then(res=>{
                this.$set(this.model,'projectName',res.result.projectName);
            }).catch(e=>{
              console.log(e)
            })
          }
        }
        this.visible = true;
      },

      // 渲染流程表单数据
      showFlowData() {
        if (this.formBpm === true) {
          let params = { id: this.formData.dataId };
          getAction(this.url.queryById, params).then((res) => {
            if (res.success) {
              this.edit(res.result);
            }
          });
        }
      },
      // 判断报销金额大于冲账金额
      handleAmount() {
        let model = this.model;
        let accumulateAmount = model.accumulateAmount
        let chargedAmount = model.chargedAmount
        if (parseFloat(accumulateAmount) < parseFloat(chargedAmount)) {
          return true;
        }
        return false;
      },
      // 支付金额数据判断
      handlePayAmount() {
        let model = this.model;
        let feeCategory = model.feeCategory
        let payAmount = model.payAmount
        if (feeCategory == '0') { // 工资福利
            // if(payAmount>model.salaryFeeInfo.amount){
            if (payAmount > model.accumulateAmount) {
              return true;
            }
        } else if (feeCategory == '1') { // 采购
            if (payAmount > model.purchaseyFeeInfo.amount) {
              return true;
            }
        } else if (feeCategory == '2') { // 费用类
            let data = model.dailyFeeInfoList;
            let amount = 0;
            data.forEach(item => {
              amount += item.amount;
            })
            amount = amount.toFixed(2);
            if (payAmount > amount) {
              return true;
            }
        }
        return false;
      },
      // 支付金额数据判断是否大于报销后的冲账剩余金额
      handlePayAndChargedAmount() {
        let model = this.model;
        let feeCategory = model.feeCategory
        let payAmount = model.payAmount
        let accumulateAmount = model.accumulateAmount
        let chargedAmount = model.chargedAmount
        let unChargedAmount = (accumulateAmount - chargedAmount).toFixed(2)
        if (feeCategory == '0') { // 工资福利
            // if(payAmount>model.salaryFeeInfo.amount){
              if (payAmount > unChargedAmount) {
              return true;
            }
        } else if (feeCategory == '1') { // 采购
            if (payAmount > unChargedAmount) {
              return true;
            }
        } else if (feeCategory == '2') { // 费用类
            if (payAmount > unChargedAmount) {
              return true;
            }
        }
        return false;
      },
      // 判断报销金额是否大于冲账金额
      handleChargedAmount() {
        let model = this.model;
        // 冲账
        if (model.settleType == '2') {
          if (model.relBillType == '2') {
            let feeCategory = model.feeCategory
            let payAmount = model.payPaidAmount
            if (feeCategory == '0') { // 工资福利
                // if(payAmount!=model.salaryFeeInfo.amount){
                if (payAmount != model.accumulateAmount) {
                  return true;
                }
            } else if (feeCategory == '1') { // 采购
                if (payAmount != model.purchaseyFeeInfo.amount) {
                  return true;
                }
            } else if (feeCategory == '2') { // 费用类
                let data = model.dailyFeeInfoList;
                let amount = 0;
                data.forEach(item => {
                  amount += item.amount;
                })
                if (payAmount != amount) {
                  return true;
                }
            }
          }
        }
        return false;
      },
      // 判断报销金额是否大于保证金服务费金额
      handleDepositChargedAmount() {
        let model = this.model;
        // 冲账
        if (model.relBillType == '3') {
          let feeCategory = model.feeCategory
          let payAmount = model.depositServiceCharge
          if (feeCategory == '0') { // 工资福利
              // if(payAmount!=model.salaryFeeInfo.amount){
              if (payAmount != model.accumulateAmount) {
                return true;
              }
          } else if (feeCategory == '1') { // 采购
              if (payAmount != model.purchaseyFeeInfo.amount) {
                return true;
              }
          } else if (feeCategory == '2') { // 费用类
              let data = model.dailyFeeInfoList;
              let amount = 0;
              data.forEach(item => {
                amount += item.amount;
              })
              if (payAmount != amount) {
                return true;
              }
          }
        }
        return false;
      },
      // 判断是否填写报销信息
      handleDataIsExist() {
        const that = this;
        let model = this.model;
        let feeCategory = model.feeCategory
        if (feeCategory == '0') {
          if (this.model.salaryFeeInfoList.length == 0) {
            that.$message.warning('请填写工资福利类报销信息');
            that.confirmLoading = false;
            that.$emit('unButtonDisable');
            return true;
          }
        } else if (feeCategory == '2') {
          if (this.model.dailyFeeInfoList.length == 0) {
            that.$message.warning('请填写费用类报销信息');
            that.confirmLoading = false;
            that.$emit('unButtonDisable');
            return true;
          }
        }
        return false;
      },

      submitForm(type) {
        const that = this;
        if (type == 'draft') {
          // 代表保存草稿不做校验
          this.submit(type)
        } else if (type == 'submit') {
          // 触发表单验证
          this.$refs.form.validate(valid => {
            if (valid) {
              if (this.handleDataIsExist()) {
              return;
            }
            if ((this.model.relBillType == '1' || this.model.relBillType == '2') && this.model.chargedInfoList.length == 0) {
              that.$message.warning('请填写冲账信息');
              that.confirmLoading = false;
              that.$emit('unButtonDisable');
              return;
            }
            if (this.handleAmount()) {
              that.$message.warning('本次冲账金额不能大于报销金额');
              that.confirmLoading = false;
              that.$emit('unButtonDisable');
              return;
            }
            if (this.handlePayAmount()) {
              that.$message.warning('本次付款金额不能大于报销金额');
              that.confirmLoading = false;
              that.$emit('unButtonDisable');
              return;
            }
            if (this.handlePayAndChargedAmount()) {
              that.$message.warning('本次付款金额不能大于报销金额冲账后的剩余金额');
              that.confirmLoading = false;
              that.$emit('unButtonDisable');
              return;
            }
              that.submit(type)
            } else {
              that.$emit('unButtonDisable')
            }
          })
        } else {
          console.log('传参数，保存：draft，提交：submit')
        }
      },
      submit (type) {
        const that = this;
        this.isSubmit = false
        let teamName = filterMultiDictText(this.dictOptions['teamManager'], that.model.teamId + '')
        let createTime = this.getCreateTime()
        let teamFeeCategory = that.getTeamFeeCategoryTitle()
        // 迭代16.7 取费用所属团队-申请人-申请日期（年月日）-金额-工资福利类/采购类/费用类（工资福利类金额取子表中报销金额之和；采购类取报销金额；费用类取子表中报销金额之和）
        that.model.bpmBizTitle = (that.model.teamId ? teamName + ' - ' : '') + that.userInfo().empName + ' - ' + createTime + (that.model.accumulateAmount ? ' - ' + that.model.accumulateAmount : '') + (teamFeeCategory ? ' - ' + teamFeeCategory : '')// 标题
        that.confirmLoading = true;
        let httpurl = '';
        let method = '';
        if (!this.model.id) {
          httpurl += this.url.add;
          method = 'post';
        } else {
          httpurl += this.url.edit;
          method = 'put';
        }
        httpAction(httpurl, this.model, method).then((res) => {
          if (res.success) {
            that.$message.success(res.message);
            if (method == 'post') {
              that.model.id = res.result;
            }
            that.$emit('ok', type, that.model);
            let params = { id: that.formData.dataId };
            getAction(that.url.queryById, params).then((res) => {
              if (res.success) {
                that.model1 = res.result
                that.isSubmit = true
              }
            });
          } else {
            that.$message.warning(res.message);
            that.$emit('unButtonDisable');
          }
        }).catch((error) => {
          that.$emit('unButtonDisable', error);
        }).finally(() => {
          that.confirmLoading = false;
        })
      },
      // 工资福利类改为子表 start
      // 工资福利类子表新增
      handleSalaryFeeInfoAdd() {
        this.$refs.salaryFee.add();
        this.$refs.salaryFee.title = '新增';
        this.$refs.salaryFee.disableSubmit = false;
        this.$refs.salaryFee.showFlowSubmitButton = false;
      },
      // 子表编辑
      handleSalaryFeeInfoEdit(record) {
        this.$refs.salaryFee.edit(record);
        this.$refs.salaryFee.title = '修改';
        this.$refs.salaryFee.disableSubmit = false;
        this.$refs.salaryFee.showFlowSubmitButton = this.showFlowSubmitButton;
      },
      // 子表复制行
      handleSalaryCopy(record) {
        let model = Object.assign({}, record);
        model.id = parseInt(Math.random() * 1000000000000);
        this.model.salaryFeeInfoList.push(JSON.parse(JSON.stringify(model)))
        // 计算总金额
        let accumulateAmount = 0
        this.model.salaryFeeInfoList.forEach(salaryFeeInfo => {
          accumulateAmount += salaryFeeInfo.amount;
        })
        this.model.accumulateAmount = accumulateAmount.toFixed(2)
      },
      // 子表删除
      handleSalaryFeeInfoDelete(id) {
        for (let i = 0; i < this.model.salaryFeeInfoList.length; i++) {
          if (this.model.salaryFeeInfoList[i].id == id) {
            this.model.salaryFeeInfoList.splice(i, 1);
          }
        }
        // 计算总金额
        let accumulateAmount = 0
        this.model.salaryFeeInfoList.forEach(salaryFeeInfo => {
          accumulateAmount += salaryFeeInfo.amount;
        })
        this.model.accumulateAmount = accumulateAmount.toFixed(2)
       // this.inputAmount(1);
      },
      // 子表提交
      modalSalaryFeeInfoFormOk(data) {
      this.loading = true;
      let flag = true;
      for (let i = 0; i < this.model.salaryFeeInfoList.length; i++) {
        if (this.model.salaryFeeInfoList[i].id == data.id) {
          this.model.salaryFeeInfoList.splice(i, 1, data);
          flag = false;
        }
      }
      if (flag) {
        this.model.salaryFeeInfoList.push(data);
      }
      // 计算总金额
      let accumulateAmount = 0
      this.model.salaryFeeInfoList.forEach(salaryFeeInfo => {
        accumulateAmount += salaryFeeInfo.amount;
      })
      this.model.accumulateAmount = accumulateAmount.toFixed(2)
      this.loading = false;
      // this.inputAmount(1);
    },

    // 冲账子表
    // 工资福利类子表新增
    handleChargedInfoAdd() {
      this.$refs.chargedInfo.add();
      this.$refs.chargedInfo.title = '新增';
      this.$refs.chargedInfo.disableSubmit = false;
      this.$refs.chargedInfo.handleDataSource(this.model.chargedInfoList);
    },
    // 子表编辑
    handleChargedInfoEdit(record) {
      this.$refs.chargedInfo.edit(record);
      this.$refs.chargedInfo.title = '修改';
      this.$refs.chargedInfo.disableSubmit = false;
      this.$refs.chargedInfo.handleDataSource(this.model.chargedInfoList);
    },
    // 子表复制行
    handleChargedInfoCopy(record) {
      let model = Object.assign({}, record);
      model.id = parseInt(Math.random() * 1000000000000);
      this.model.chargedInfoList.push(JSON.parse(JSON.stringify(model)))
      // 计算总金额
      this.handelCharedAmount()
    },
    // 子表删除
    handleChargedInfoDelete(id) {
      for (let i = 0; i < this.model.chargedInfoList.length; i++) {
        if (this.model.chargedInfoList[i].id == id) {
          this.model.chargedInfoList.splice(i, 1);
        }
      }
      // 计算总金额
      this.handelCharedAmount()
    },
      // 子表提交
      modalChargedInfoFormOk(data) {
      this.loading = true;
      let flag = true;
      for (let i = 0; i < this.model.chargedInfoList.length; i++) {
        if (this.model.chargedInfoList[i].id == data.id) {
          this.model.chargedInfoList.splice(i, 1, data);
          flag = false;
        }
      }
      if (flag) {
        this.model.chargedInfoList.push(data);
      }
      this.$refs.chargedInfo.handleDataSource(this.model.chargedInfoList);
      // 计算总金额
      this.handelCharedAmount()
      this.loading = false;
    },
    handelCharedAmount() {
      let chargedAmount = 0
      this.model.chargedInfoList.forEach(item => {
        chargedAmount += item.chargedAmount;
      })
      this.model.chargedAmount = chargedAmount.toFixed(2)
    },
    // 点击打印
    onPrint () {
      let print = new Print({
        el: '#reimbursementContent',
        popTitle: '费用报销详情 · 禾美环保',
        endCallback() {

        }
      })
    },
    getCreateTime() {
      let createTime = this.model.createTime;
      let date = createTime.substring(0, 10)
      return date.substring(0, 4) + '年' + date.substring(5, 7) + '月' + date.substring(8, 10) + '日';
    },
    getTeamFeeCategoryTitle() {
      let feeCategory = ''
      switch (this.model.feeCategory) {
        case '0': feeCategory = '工资福利类'; break;
        case '1': feeCategory = '采购类'; break;
        case '2': feeCategory = '费用类'; break;
      }
      return feeCategory;
    }
    }
  }
</script>
<style lang="less" scoped>
.print_style{
  position: absolute;
  top: 0;
  z-index: -1111;
}
</style>

